mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
parent
2ddf26b8c3
commit
94e1d4567a
6 changed files with 51 additions and 2 deletions
|
@ -48,6 +48,15 @@ module Ameba::Rule::Performance
|
|||
end
|
||||
end
|
||||
|
||||
context "macro" do
|
||||
it "reports in macro scope" do
|
||||
source = Source.new %(
|
||||
{{ [1, 2, 3].reject { |e| e > 2 }.any? }}
|
||||
)
|
||||
subject.catch(source).should_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new %(
|
||||
[1, 2, 3].reject { |e| e > 2 }.any?
|
||||
|
|
|
@ -107,6 +107,15 @@ module Ameba::Rule::Performance
|
|||
issue.message.should eq "Use `reverse_each.find {...}` instead of `select {...}.last`"
|
||||
end
|
||||
|
||||
context "macro" do
|
||||
it "doesn't report in macro scope" do
|
||||
source = Source.new %(
|
||||
{{[1, 2, 3].select { |e| e > 2 }.last }}
|
||||
)
|
||||
subject.catch(source).should be_valid
|
||||
end
|
||||
end
|
||||
|
||||
it "reports a correct message for last?" do
|
||||
s = Source.new %(
|
||||
[1, 2, 3].select { |e| e > 2 }.last?
|
||||
|
|
|
@ -49,6 +49,15 @@ module Ameba::Rule::Performance
|
|||
end
|
||||
end
|
||||
|
||||
context "macro" do
|
||||
it "doesn't report in macro scope" do
|
||||
source = Source.new %(
|
||||
{{[1, 2, 3].select { |v| v > 1 }.size}}
|
||||
)
|
||||
subject.catch(source).should be_valid
|
||||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new %(
|
||||
lines.split("\n").reject(&.empty?).size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue