From cc736a63e9f1ae4e3a9adf9c33b5b38fe66fe99a Mon Sep 17 00:00:00 2001 From: Damir Svrtan Date: Sun, 20 Aug 2023 11:28:40 -0700 Subject: [PATCH] Redis keys method should not trigger the each key recommendation --- lib/fasterer/scanners/method_call_scanner.rb | 4 +++- spec/support/analyzer/15_keys_each_vs_each_key.rb | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/fasterer/scanners/method_call_scanner.rb b/lib/fasterer/scanners/method_call_scanner.rb index a020c8d..5353c52 100644 --- a/lib/fasterer/scanners/method_call_scanner.rb +++ b/lib/fasterer/scanners/method_call_scanner.rb @@ -99,7 +99,9 @@ def check_each_offense when :reverse add_offense(:reverse_each_vs_reverse_each) when :keys - add_offense(:keys_each_vs_each_key) + if method_call.receiver.arguments.count.zero? + add_offense(:keys_each_vs_each_key) + end end end diff --git a/spec/support/analyzer/15_keys_each_vs_each_key.rb b/spec/support/analyzer/15_keys_each_vs_each_key.rb index 31436db..ebeb2ca 100644 --- a/spec/support/analyzer/15_keys_each_vs_each_key.rb +++ b/spec/support/analyzer/15_keys_each_vs_each_key.rb @@ -13,3 +13,7 @@ end HASH.each_key(&:to_sym) + +@redis.keys('queue:*').each do |queue_name| + puts queue_name +end