RuboCop::Cop
Checks for uses of if with a negated condition. Only ifs without else are considered.
# File lib/rubocop/cop/style/negated_if.rb, line 19 def message(node) if node.loc.keyword.is?('if') format(MSG, 'unless', 'if') else format(MSG, 'if', 'unless') end end
# File lib/rubocop/cop/style/negated_if.rb, line 12 def on_if(node) return unless node.loc.respond_to?(:keyword) return if node.loc.keyword.is?('elsif') check(node) end
[Validate]
Generated with the Darkfish Rdoc Generator 2.