diff --git a/spec/ameba/rule/performance/any_instead_of_empty_spec.cr b/spec/ameba/rule/performance/any_instead_of_empty_spec.cr index e598a327..2b637a8f 100644 --- a/spec/ameba/rule/performance/any_instead_of_empty_spec.cr +++ b/spec/ameba/rule/performance/any_instead_of_empty_spec.cr @@ -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 diff --git a/src/ameba/rule/performance/any_instead_of_empty.cr b/src/ameba/rule/performance/any_instead_of_empty.cr index ca0f5547..77ac4cea 100644 --- a/src/ameba/rule/performance/any_instead_of_empty.cr +++ b/src/ameba/rule/performance/any_instead_of_empty.cr @@ -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