Class: RuboCop::Cop::OrderedGemCorrector

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

Overview

This autocorrects 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.



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

def comments_as_separators
  @comments_as_separators
end

.processed_sourceObject (readonly)

Returns the value of attribute processed_source.



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

def processed_source
  @processed_source
end

Class Method Details

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



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

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)

  ->(corrector) { corrector.swap(current_range, previous_range) }
end