class RuboCop::Cop::Lint::RequireParentheses

if day.is?(:tuesday) && month == :jan
# good
@example
end

if day.is? :tuesday && month == :jan
# bad
@example
an operand of &&/||.
be under the impression that the return value from the method call is
The idea behind warning for these constructs is that the user might
last argument.
the parameter list, and a boolean operator, && or ||, is used in the
method with at least one argument, where no parentheses are used around
This cop checks for expressions where there is a call to a predicate

def check_predicate(predicate, node)

def check_predicate(predicate, node)
  return unless offense?(predicate)
  add_offense(node, :expression)
end

def check_ternary(ternary, node)

def check_ternary(ternary, node)
  return unless offense?(ternary.condition)
  range = range_between(node.source_range.begin_pos,
                        ternary.condition.source_range.end_pos)
  add_offense(range, range)
end

def offense?(node)

def offense?(node)
  [:and, :or].include?(node.type)
end

def on_send(node)

def on_send(node)
  _receiver, method_name, *args = *node
  return if parentheses?(node) || args.empty?
  if args.first.if_type? && args.first.ternary?
    check_ternary(args.first, node)
  elsif method_name.to_s.end_with?('?')
    check_predicate(args.last, node)
  end
end