class RubbyCop::Cop::Lint::AmbiguousOperator

This cop checks for ambiguous operators in the first argument of a method invocation without parentheses.

@example

# bad

# The `*` is interpreted as a splat operator but it could possibly be
# a `*` method invocation (i.e. `do_something.*(some_array)`).
do_something *some_array

@example

# good

# With parentheses, there's no ambiguity.
do_something(*some_array)

Constants

AMBIGUITIES
MSG_FORMAT

Private Instance Methods

alternative_message(diagnostic) click to toggle source
# File lib/rubbycop/cop/lint/ambiguous_operator.rb, line 47
def alternative_message(diagnostic)
  operator = diagnostic.location.source
  hash = AMBIGUITIES[operator]
  format(MSG_FORMAT, hash)
end
relevant_diagnostic?(diagnostic) click to toggle source
# File lib/rubbycop/cop/lint/ambiguous_operator.rb, line 43
def relevant_diagnostic?(diagnostic)
  diagnostic.reason == :ambiguous_prefix
end