mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Fix regression in AnyInsteadOfEmpty
rule
This commit is contained in:
parent
73bd1ba5a3
commit
fbd72a5171
2 changed files with 4 additions and 4 deletions
|
@ -16,7 +16,7 @@ module Ameba::Rule::Performance
|
|||
it "reports if there is any? call without a block nor argument" do
|
||||
source = expect_issue subject, <<-CRYSTAL
|
||||
[1, 2, 3].any?
|
||||
# ^^^^^^^^^^^^ error: Use `!{...}.empty?` instead of `{...}.any?`
|
||||
# ^^^^ error: Use `!{...}.empty?` instead of `{...}.any?`
|
||||
CRYSTAL
|
||||
|
||||
expect_correction source, <<-CRYSTAL
|
||||
|
@ -34,7 +34,7 @@ module Ameba::Rule::Performance
|
|||
it "reports in macro scope" do
|
||||
source = expect_issue subject, <<-CRYSTAL
|
||||
{{ [1, 2, 3].any? }}
|
||||
# ^^^^^^^^^^^^^^ error: Use `!{...}.empty?` instead of `{...}.any?`
|
||||
# ^^^^ error: Use `!{...}.empty?` instead of `{...}.any?`
|
||||
CRYSTAL
|
||||
|
||||
expect_correction source, <<-CRYSTAL
|
||||
|
@ -51,7 +51,7 @@ module Ameba::Rule::Performance
|
|||
issue = source.issues.first
|
||||
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:1:1"
|
||||
issue.location.to_s.should eq "source.cr:1:11"
|
||||
issue.end_location.to_s.should eq "source.cr:1:14"
|
||||
issue.message.should eq "Use `!{...}.empty?` instead of `{...}.any?`"
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ module Ameba::Rule::Performance
|
|||
return unless name_location = node.name_location
|
||||
return unless end_location = name_end_location(node)
|
||||
|
||||
issue_for location, end_location, MSG do |corrector|
|
||||
issue_for name_location, end_location, MSG do |corrector|
|
||||
corrector.insert_before(location, '!')
|
||||
corrector.replace(name_location, end_location, "empty?")
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue