class RuboCop::Cop::Lint::AmbiguousRegexpLiteral

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

@example

# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

# With parentheses, there's no ambiguity.
do_something(/pattern/i)

Constants

MSG

Private Instance Methods

alternative_message(_diagnostic) click to toggle source
# File lib/rubocop/cop/lint/ambiguous_regexp_literal.rb, line 30
def alternative_message(_diagnostic)
  MSG
end
relevant_diagnostic?(diagnostic) click to toggle source
# File lib/rubocop/cop/lint/ambiguous_regexp_literal.rb, line 26
def relevant_diagnostic?(diagnostic)
  diagnostic.reason == :ambiguous_literal
end