class RuboCop::Cop::Style::NegatedWhile
Checks for uses of while with a negated condition.
@example
# bad while !foo bar end # good until foo bar end # bad bar until !foo # good bar while foo bar while !foo && baz
Public Instance Methods
autocorrect(node)
click to toggle source
# File lib/rubocop/cop/style/negated_while.rb, line 36 def autocorrect(node) ConditionCorrector.correct_negative_condition(node) end
on_until(node)
click to toggle source
# File lib/rubocop/cop/style/negated_while.rb, line 32 def on_until(node) check_negative_conditional(node) end
on_while(node)
click to toggle source
# File lib/rubocop/cop/style/negated_while.rb, line 28 def on_while(node) check_negative_conditional(node) end
Private Instance Methods
message(node)
click to toggle source
# File lib/rubocop/cop/style/negated_while.rb, line 42 def message(node) format(MSG, inverse: node.inverse_keyword, current: node.keyword) end