Class: RuboCop::Cop::OrderedGemCorrector

Inherits:
Object
  • Object
show all
Extended by:
OrderedGemNode
Defined in:
lib/rubocop/cop/correctors/ordered_gem_corrector.rb

Overview

This auto-corrects gem dependency order

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.comments_as_separatorsObject (readonly)

Returns the value of attribute comments_as_separators.



10
11
12
# File 'lib/rubocop/cop/correctors/ordered_gem_corrector.rb', line 10

def comments_as_separators
  @comments_as_separators
end

.processed_sourceObject (readonly)

Returns the value of attribute processed_source.



10
11
12
# File 'lib/rubocop/cop/correctors/ordered_gem_corrector.rb', line 10

def processed_source
  @processed_source
end

Class Method Details

.correct(processed_source, node, previous_declaration, comments_as_separators) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rubocop/cop/correctors/ordered_gem_corrector.rb', line 12

def correct(processed_source, node,
            previous_declaration, comments_as_separators)
  @processed_source = processed_source
  @comments_as_separators = comments_as_separators

  current_range = declaration_with_comment(node)
  previous_range = declaration_with_comment(previous_declaration)

  lambda do |corrector|
    swap_range(corrector, current_range, previous_range)
  end
end