class RuboCop::Cop::Performance::RangeInclude

(‘a’..‘z’).cover?(‘b’) # => true
# good
(‘a’..‘z’).member?(‘b’) # => true
(‘a’..‘z’).include?(‘b’) # => true
# bad
@example
—-
(‘a’..‘z’).cover?(‘yellow’) # => true
—-
[source,ruby]

Example of a case where ‘Range#cover?` may not provide the desired result:
are not equivalent behavior.
This cop is unsafe because `Range#include?` (or `Range#member?`) and `Range#cover?`
@safety
is wanted.
end points of the `Range`. In a great majority of cases, this is what
`Range#cover?` simply compares the target item with the beginning and
item in a `Range` to see if a specified item is there. In contrast,
Identifies uses of `Range#include?` and `Range#member?`, which iterates over each

def on_send(node)

def on_send(node)
  range_include(node) do |bad_method|
    message = format(MSG, bad_method: bad_method)
    add_offense(node.loc.selector, message: message) do |corrector|
      corrector.replace(node.loc.selector, 'cover?')
    end
  end
end