class RuboCop::Cop::Performance::RangeInclude
(‘a’..‘z’).cover?(‘yellow’) # => true
desired result:
Here is an example of a case where ‘Range#cover?` may not provide the
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,
This cop identifies uses of `Range#include?`, which iterates over each
def autocorrect(node)
def autocorrect(node) ->(corrector) { corrector.replace(node.loc.selector, 'cover?') } end
def on_send(node)
def on_send(node) return unless range_include(node) add_offense(node, location: :selector) end