From 9abc15c4e81e6ebd3dc091dd81ff107d62bcd34b Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sat, 12 Sep 2020 15:22:26 +0900 Subject: [PATCH] Use `RESTRICT_ON_SEND` for `Lint/IdentityComparison` Follow https://github.com/rubocop-hq/rubocop/pull/8699#issuecomment-691098197 and #8606. This PR uses `RESTRICT_ON_SEND` for `Lint/IdentityComparison`. --- lib/rubocop/cop/lint/identity_comparison.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/rubocop/cop/lint/identity_comparison.rb b/lib/rubocop/cop/lint/identity_comparison.rb index 89257355858..c1b6d6d74ca 100644 --- a/lib/rubocop/cop/lint/identity_comparison.rb +++ b/lib/rubocop/cop/lint/identity_comparison.rb @@ -20,6 +20,7 @@ class IdentityComparison < Base extend AutoCorrector MSG = 'Use `equal?` instead `==` when comparing `object_id`.' + RESTRICT_ON_SEND = %i[==].freeze def on_send(node) return unless compare_between_object_id_by_double_equal?(node) @@ -36,8 +37,6 @@ def on_send(node) private def compare_between_object_id_by_double_equal?(node) - return false unless node.method?(:==) - object_id_method?(node.receiver) && object_id_method?(node.first_argument) end