class RuboCop::Cop::Rails::NegateInclude
hash.exclude?(:key)
array.exclude?(2)
# good
!hash.include?(:key)
!array.include?(2)
# bad
@example
receiver objects that do not have an ‘exclude?` method. (e.g. `IPAddr`)
This cop is unsafe because false positive will occur for
@safety
over `!collection.include?(obj)`.
Enforces the use of `collection.exclude?(obj)`
def on_send(node)
def on_send(node) return unless (receiver, obj = negate_include_call?(node)) add_offense(node) do |corrector| corrector.replace(node, "#{receiver.source}.exclude?(#{obj.source})") end end