123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::Cop::ConditionCorrector

Relationships & Source Files
Inherits: Object
Defined in: lib/rubocop/cop/correctors/condition_corrector.rb

Overview

This class does condition autocorrection

Class Method Summary

Class Method Details

.correct_negative_condition(corrector, node)

[ GitHub ]

  
# File 'lib/rubocop/cop/correctors/condition_corrector.rb', line 8

def correct_negative_condition(corrector, node)
  condition = negated_condition(node)

  corrector.replace(node.loc.keyword, node.inverse_keyword)
  corrector.replace(condition, condition.children.first.source)
end

.negated_condition(node) (private)

[ GitHub ]

  
# File 'lib/rubocop/cop/correctors/condition_corrector.rb', line 17

def negated_condition(node)
  condition = node.condition
  condition = condition.children.first while condition.begin_type?
  condition
end