From 82e0e5308010cb53774770d08fb222764fbed049 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Fri, 17 Nov 2023 19:48:41 +0100 Subject: [PATCH] Revert "Fix `Performance/ExcessiveAllocations` to exclude `each` calls without a block" This reverts commit 29e29b8e1d04b9126fb692e2da930a6536d3bceb. --- spec/ameba/rule/performance/excessive_allocations_spec.cr | 1 - src/ameba/rule/performance/excessive_allocations.cr | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/ameba/rule/performance/excessive_allocations_spec.cr b/spec/ameba/rule/performance/excessive_allocations_spec.cr index 339d90c0..010c5064 100644 --- a/spec/ameba/rule/performance/excessive_allocations_spec.cr +++ b/spec/ameba/rule/performance/excessive_allocations_spec.cr @@ -6,7 +6,6 @@ module Ameba::Rule::Performance describe ExcessiveAllocations do it "passes if there is no potential performance improvements" do expect_no_issues subject, <<-CRYSTAL - "Alice".chars.each "Alice".chars.each(arg) { |c| puts c } "Alice".chars(arg).each { |c| puts c } "Alice\nBob".lines.each(arg) { |l| puts l } diff --git a/src/ameba/rule/performance/excessive_allocations.cr b/src/ameba/rule/performance/excessive_allocations.cr index 41250dfd..e8677d74 100644 --- a/src/ameba/rule/performance/excessive_allocations.cr +++ b/src/ameba/rule/performance/excessive_allocations.cr @@ -52,7 +52,7 @@ module Ameba::Rule::Performance end def test(source, node : Crystal::Call) - return unless node.name == "each" && node.args.empty? && node.block + return unless node.name == "each" && node.args.empty? return unless (obj = node.obj).is_a?(Crystal::Call) return unless obj.args.empty? && obj.block.nil? return unless method = call_names[obj.name]?