lib/rubocop/cop/style/negated_if.rb in rubocop-0.89.1 vs lib/rubocop/cop/style/negated_if.rb in rubocop-0.90.0
- old
+ new
@@ -66,22 +66,22 @@
# # good
#
# if !foo
# bar
# end
- class NegatedIf < Cop
+ class NegatedIf < Base
include ConfigurableEnforcedStyle
include NegativeConditional
+ extend AutoCorrector
def on_if(node)
return if node.unless? || node.elsif? || node.ternary?
return if correct_style?(node)
- check_negative_conditional(node)
- end
-
- def autocorrect(node)
- ConditionCorrector.correct_negative_condition(node)
+ message = message(node)
+ check_negative_conditional(node, message: message) do |corrector|
+ ConditionCorrector.correct_negative_condition(corrector, node)
+ end
end
private
def message(node)