Remove buggy auto-correction from `Performance/AnyInsteadOfEmpty` rule

This commit is contained in:
Sijawusz Pur Rahnama 2023-01-04 02:40:07 +01:00
parent f7cb5bb563
commit 6f0b6ffcd0
2 changed files with 3 additions and 15 deletions

View File

@ -14,14 +14,10 @@ module Ameba::Rule::Performance
end
it "reports if there is any? call without a block nor argument" do
source = expect_issue subject, <<-CRYSTAL
expect_issue subject, <<-CRYSTAL
[1, 2, 3].any?
# ^^^^ error: Use `!{...}.empty?` instead of `{...}.any?`
CRYSTAL
expect_correction source, <<-CRYSTAL
![1, 2, 3].empty?
CRYSTAL
end
it "does not report if source is a spec" do
@ -32,14 +28,10 @@ module Ameba::Rule::Performance
context "macro" do
it "reports in macro scope" do
source = expect_issue subject, <<-CRYSTAL
expect_issue subject, <<-CRYSTAL
{{ [1, 2, 3].any? }}
# ^^^^ error: Use `!{...}.empty?` instead of `{...}.any?`
CRYSTAL
expect_correction source, <<-CRYSTAL
{{ ![1, 2, 3].empty? }}
CRYSTAL
end
end
end

View File

@ -42,14 +42,10 @@ module Ameba::Rule::Performance
return unless node.block.nil? && node.args.empty?
return unless node.obj
return unless location = node.location
return unless name_location = node.name_location
return unless end_location = name_end_location(node)
issue_for name_location, end_location, MSG do |corrector|
corrector.insert_before(location, '!')
corrector.replace(name_location, end_location, "empty?")
end
issue_for name_location, end_location, MSG
end
end
end