This cop checks for expressions where there is a call to a predicate method with at least one argument, where no parentheses are used around the parameter list, and a boolean operator, && or ||, is used in the last argument.
The idea behind warning for these constructs is that the user might be under the impression that the return value from the method call is an operand of &&/||.
@example
if day.is? :tuesday && month == :jan
...
end
# File lib/rubocop/cop/lint/require_parentheses.rb, line 25 def on_send(node) _receiver, method_name, *args = *node return if parentheses?(node) return if args.empty? if ternary_op?(args.first) check_ternary(args.first, node) else # We're only checking predicate methods. There would be false # positives otherwise. check_send(args.last, node) if predicate?(method_name) end end
Generated with the Darkfish Rdoc Generator 2.