lib/rubocop/cop/style/negated_if.rb in rubocop-0.49.1 vs lib/rubocop/cop/style/negated_if.rb in rubocop-0.50.0
- old
+ new
@@ -80,23 +80,27 @@
MSG = 'Favor `%s` over `%s` for negative conditions.'.freeze
def on_if(node)
return if node.elsif? || node.ternary?
- return if style == :prefix && node.modifier_form?
- return if style == :postfix && !node.modifier_form?
+ return if correct_style?(node)
check_negative_conditional(node)
end
+ private
+
def message(node)
format(MSG, node.inverse_keyword, node.keyword)
end
- private
-
def autocorrect(node)
negative_conditional_corrector(node)
+ end
+
+ def correct_style?(node)
+ style == :prefix && node.modifier_form? ||
+ style == :postfix && !node.modifier_form?
end
end
end
end
end