Module: RuboCop::Cop::OrderedGemNode

Included in:
Bundler::OrderedGems, Gemspec::OrderedDependencies
Defined in:
lib/rubocop/cop/mixin/ordered_gem_node.rb

Overview

Common functionality for Bundler/OrderedGems and Gemspec/OrderedDependencies.

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/rubocop/cop/mixin/ordered_gem_node.rb', line 8

def autocorrect(node)
  previous = previous_declaration(node)

  current_range = declaration_with_comment(node)
  previous_range = declaration_with_comment(previous)

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