mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Remove most of the obsolete specs
This commit is contained in:
parent
1ba6fcb55c
commit
9926f0295a
36 changed files with 0 additions and 513 deletions
|
@ -66,14 +66,5 @@ module Ameba::Rule::Performance
|
|||
expect_no_corrections source
|
||||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
source = expect_issue subject, <<-CRYSTAL
|
||||
[1, 2, 3].reject { |e| e > 2 }.any?
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `reject {...}.any?`
|
||||
CRYSTAL
|
||||
|
||||
expect_no_corrections source
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,18 +42,5 @@ module Ameba::Rule::Performance
|
|||
CRYSTAL
|
||||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
source = Source.new path: "source.cr", code: %(
|
||||
[1, 2, 3].any?
|
||||
)
|
||||
subject.catch(source).should_not be_valid
|
||||
issue = source.issues.first
|
||||
|
||||
issue.rule.should_not be_nil
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
|
@ -54,22 +54,6 @@ module Ameba::Rule::Performance
|
|||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
source = Source.new path: "source.cr", code: <<-CODE
|
||||
[1, 2, 3].select { |e| e > 1 }.reverse
|
||||
CODE
|
||||
|
||||
subject.catch(source).should_not be_valid
|
||||
source.issues.size.should eq 1
|
||||
|
||||
issue = source.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:1:32"
|
||||
issue.end_location.to_s.should eq "source.cr:1:38"
|
||||
|
||||
issue.message.should eq "Use bang method variant `reverse!` after chained `select` call"
|
||||
end
|
||||
|
||||
context "macro" do
|
||||
it "doesn't report in macro scope" do
|
||||
expect_no_issues subject, <<-CRYSTAL
|
||||
|
|
|
@ -36,18 +36,5 @@ module Ameba::Rule::Performance
|
|||
CRYSTAL
|
||||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new %(
|
||||
(1..3).map(&.itself).compact
|
||||
), "source.cr"
|
||||
subject.catch(s).should_not be_valid
|
||||
issue = s.issues.first
|
||||
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:1:8"
|
||||
issue.end_location.to_s.should eq "source.cr:1:29"
|
||||
issue.message.should eq "Use `compact_map {...}` instead of `map {...}.compact`"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -72,21 +72,6 @@ module Ameba::Rule::Performance
|
|||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new %(
|
||||
[1, 2, 3].select { |e| e > 2 }.first
|
||||
), "source.cr"
|
||||
subject.catch(s).should_not be_valid
|
||||
s.issues.size.should eq 1
|
||||
|
||||
issue = s.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:1:11"
|
||||
issue.end_location.to_s.should eq "source.cr:1:37"
|
||||
|
||||
issue.message.should eq "Use `find {...}` instead of `select {...}.first`"
|
||||
end
|
||||
|
||||
context "macro" do
|
||||
it "doesn't report in macro scope" do
|
||||
expect_no_issues subject, <<-CRYSTAL
|
||||
|
|
|
@ -30,18 +30,5 @@ module Ameba::Rule::Performance
|
|||
CRYSTAL
|
||||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new %(
|
||||
%w[Alice Bob].map(&.chars).flatten
|
||||
), "source.cr"
|
||||
subject.catch(s).should_not be_valid
|
||||
issue = s.issues.first
|
||||
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:1:15"
|
||||
issue.end_location.to_s.should eq "source.cr:1:35"
|
||||
issue.message.should eq "Use `flat_map {...}` instead of `map {...}.flatten`"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,18 +45,5 @@ module Ameba::Rule::Performance
|
|||
CRYSTAL
|
||||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new %(
|
||||
(1..3).map(&.to_u64).sum
|
||||
), "source.cr"
|
||||
subject.catch(s).should_not be_valid
|
||||
issue = s.issues.first
|
||||
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:1:8"
|
||||
issue.end_location.to_s.should eq "source.cr:1:25"
|
||||
issue.message.should eq "Use `sum {...}` instead of `map {...}.sum`"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -61,18 +61,5 @@ module Ameba::Rule::Performance
|
|||
CRYSTAL
|
||||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new %(
|
||||
lines.split("\n").reject(&.empty?).size
|
||||
), "source.cr"
|
||||
subject.catch(s).should_not be_valid
|
||||
issue = s.issues.first
|
||||
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:2:4"
|
||||
issue.end_location.to_s.should eq "source.cr:2:25"
|
||||
issue.message.should eq "Use `count {...}` instead of `reject {...}.size`."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue