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
|
@ -94,16 +94,6 @@ module Ameba::Rule::Lint
|
|||
a
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
source = Source.new "a != true", "source.cr"
|
||||
subject.catch(source)
|
||||
|
||||
issue = source.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:1:1"
|
||||
issue.message.should eq "Comparison to a boolean is pointless"
|
||||
end
|
||||
end
|
||||
|
||||
context "boolean on the left" do
|
||||
|
@ -165,17 +155,6 @@ module Ameba::Rule::Lint
|
|||
a
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
source = Source.new "true != a", "source.cr"
|
||||
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:1"
|
||||
issue.end_location.to_s.should eq "source.cr:1:9"
|
||||
issue.message.should eq "Comparison to a boolean is pointless"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,16 +28,5 @@ module Ameba::Rule::Lint
|
|||
CRYSTAL
|
||||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new "pp! :foo", "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:1"
|
||||
issue.end_location.to_s.should eq "source.cr:1:8"
|
||||
issue.message.should eq "Possibly forgotten debug-related `pp!` call detected"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,16 +31,5 @@ module Ameba::Rule::Lint
|
|||
|
||||
expect_no_corrections source
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new "debugger", "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:1"
|
||||
issue.end_location.to_s.should eq "source.cr:1:8"
|
||||
issue.message.should eq "Possible forgotten debugger statement detected"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,28 +22,5 @@ module Ameba::Rule::Lint
|
|||
|
||||
expect_no_corrections source
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
source = Source.new <<-CRYSTAL, "source.cr"
|
||||
require "./thing"
|
||||
require "./thing"
|
||||
require "./another_thing"
|
||||
require "./another_thing"
|
||||
CRYSTAL
|
||||
|
||||
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:2:1"
|
||||
issue.end_location.to_s.should eq ""
|
||||
issue.message.should eq "Duplicated require of `./thing`"
|
||||
|
||||
issue = source.issues.last
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:4:1"
|
||||
issue.end_location.to_s.should eq ""
|
||||
issue.message.should eq "Duplicated require of `./another_thing`"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -110,18 +110,5 @@ module Ameba
|
|||
)
|
||||
subject.catch(s).should be_valid
|
||||
end
|
||||
|
||||
it "reports rule, location and message" do
|
||||
s = Source.new %(
|
||||
if ()
|
||||
end
|
||||
), "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:4"
|
||||
issue.end_location.to_s.should eq "source.cr:1:5"
|
||||
issue.message.should eq "Avoid empty expressions"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -64,21 +64,5 @@ module Ameba::Rule::Lint
|
|||
end
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports rule, message and location" do
|
||||
s = Source.new %(
|
||||
a = 1
|
||||
loop do
|
||||
# comment goes here
|
||||
end
|
||||
), "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:2:1"
|
||||
issue.end_location.to_s.should eq "source.cr:4:3"
|
||||
issue.message.should eq EmptyLoop::MSG
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,17 +32,5 @@ module Ameba::Rule::Lint
|
|||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Duplicated keys in hash literal: "key1", "key2"
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports rule, location and message" do
|
||||
s = Source.new %q(
|
||||
h = {"a" => 1, "a" => 2}
|
||||
), "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:5"
|
||||
issue.end_location.to_s.should eq "source.cr:1:24"
|
||||
issue.message.should eq %(Duplicated keys in hash literal: "a")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -58,18 +58,5 @@ module Ameba::Rule::Lint
|
|||
CRYSTAL
|
||||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new %(
|
||||
"foo" == "foo"
|
||||
), "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:1"
|
||||
issue.end_location.to_s.should eq "source.cr:1:14"
|
||||
issue.message.should eq "Comparison always evaluates to true"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -58,18 +58,5 @@ module Ameba::Rule::Lint
|
|||
CRYSTAL
|
||||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new %(
|
||||
(1..3).index(1).not_nil!
|
||||
), "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:24"
|
||||
issue.message.should eq "Use `index! {...}` instead of `index {...}.not_nil!`"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,18 +32,5 @@ module Ameba::Rule::Lint
|
|||
CRYSTAL
|
||||
end
|
||||
end
|
||||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new %(
|
||||
(1..3).first?.not_nil!
|
||||
), "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:22"
|
||||
issue.message.should eq "Avoid using `not_nil!`"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,16 +25,5 @@ module Ameba::Rule::Lint
|
|||
# ^^^^^ error: rand(1) always returns 0
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports rule, location and a message" do
|
||||
s = Source.new "rand(1)", "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:1"
|
||||
issue.end_location.to_s.should eq "source.cr:1:7"
|
||||
issue.message.should eq "rand(1) always returns 0"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -157,20 +157,6 @@ module Ameba::Rule::Lint
|
|||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports rule, location and message" do
|
||||
source = Source.new %(
|
||||
foo = 1
|
||||
3.times { |foo| foo + 1 }
|
||||
), "source.cr"
|
||||
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:2:12"
|
||||
issue.end_location.should be_nil
|
||||
issue.message.should eq "Shadowing outer local variable `foo`"
|
||||
end
|
||||
|
||||
context "macro" do
|
||||
it "does not report shadowed vars in outer scope" do
|
||||
expect_no_issues subject, <<-CRYSTAL
|
||||
|
|
|
@ -194,24 +194,5 @@ module Ameba::Rule::Lint
|
|||
end
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports rule, location and message" do
|
||||
s = Source.new %(
|
||||
i = 0
|
||||
while true
|
||||
i += 1
|
||||
spawn { i }
|
||||
end
|
||||
), "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:4:11"
|
||||
issue.end_location.to_s.should eq "source.cr:4:11"
|
||||
issue.message.should eq "Shared variable `i` is used in fiber"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,16 +23,6 @@ module Ameba::Rule::Lint
|
|||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports rule, location and message" do
|
||||
s = Source.new "def hello end", "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:11"
|
||||
issue.message.should match /unexpected token: "?end"? \(expected ["'];["'] or newline\)/
|
||||
end
|
||||
|
||||
it "has highest severity" do
|
||||
subject.severity.should eq Severity::Error
|
||||
end
|
||||
|
|
|
@ -24,22 +24,5 @@ module Ameba::Rule::Lint
|
|||
end
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports rule, location and message" do
|
||||
s = Source.new %(
|
||||
case
|
||||
when String
|
||||
puts "hello"
|
||||
when can_generate?
|
||||
generate if can_generate?
|
||||
end
|
||||
), "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:5:15"
|
||||
issue.end_location.to_s.should eq "source.cr:5:27"
|
||||
issue.message.should eq "Useless condition in when detected"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue