Class: RuboCop::Cop::ConditionCorrector

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/correctors/condition_corrector.rb

Overview

This class does condition auto-correction

Class Method Summary collapse

Class Method Details

.correct_negative_condition(node) ⇒ Object


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

def correct_negative_condition(node)
  condition = negated_condition(node)

  lambda do |corrector|
    corrector.replace(node.loc.keyword, node.inverse_keyword)
    corrector.replace(condition.source_range,
                      condition.children.first.source)
  end
end