mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Normalize sources for tests
This commit is contained in:
parent
cb5f802012
commit
d7b0e10d1e
27 changed files with 89 additions and 65 deletions
|
@ -61,7 +61,7 @@ module Ameba::Rule::Lint
|
|||
issue = s.issues.first
|
||||
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:3:11"
|
||||
issue.location.to_s.should eq "source.cr:2:3"
|
||||
issue.message.should eq "Empty `ensure` block detected"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -103,7 +103,7 @@ module Ameba
|
|||
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:12"
|
||||
issue.location.to_s.should eq "source.cr:1:4"
|
||||
issue.message.should eq "Avoid empty expressions"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ module Ameba::Rule::Lint
|
|||
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:13"
|
||||
issue.location.to_s.should eq "source.cr:1:5"
|
||||
issue.message.should eq %(Duplicated keys in hash literal: "a")
|
||||
end
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ module Ameba::Rule::Lint
|
|||
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:9"
|
||||
issue.location.to_s.should eq "source.cr:1:1"
|
||||
issue.message.should eq "Literal value found in conditional"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,7 +46,7 @@ module Ameba::Rule::Lint
|
|||
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:9"
|
||||
issue.location.to_s.should eq "source.cr:1:1"
|
||||
issue.message.should eq(
|
||||
"Symbols `,:` may be unwanted in %i array literals"
|
||||
)
|
||||
|
@ -60,7 +60,7 @@ module Ameba::Rule::Lint
|
|||
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:9"
|
||||
issue.location.to_s.should eq "source.cr:1:1"
|
||||
issue.message.should eq(
|
||||
"Symbols `,\"` may be unwanted in %w array literals"
|
||||
)
|
||||
|
|
|
@ -158,7 +158,7 @@ module Ameba::Rule::Lint
|
|||
|
||||
issue = s.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:3:11"
|
||||
issue.location.to_s.should eq "source.cr:2:3"
|
||||
issue.message.should eq "Argument `bar` is assigned before it is used"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -166,7 +166,7 @@ module Ameba::Rule::Lint
|
|||
issue = s.issues.first
|
||||
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:3:11"
|
||||
issue.location.to_s.should eq "source.cr:2:3"
|
||||
issue.message.should eq(
|
||||
"Exception handler has shadowed exceptions: IndexError"
|
||||
)
|
||||
|
|
|
@ -160,7 +160,7 @@ module Ameba::Rule::Lint
|
|||
|
||||
issue = source.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:3:20"
|
||||
issue.location.to_s.should eq "source.cr:2:12"
|
||||
issue.message.should eq "Shadowing outer local variable `foo`"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ module Ameba::Rule::Lint
|
|||
# ameba:disable #{NamedRule.name}
|
||||
a = 1
|
||||
)
|
||||
s.add_issue NamedRule.new, location: {3, 9},
|
||||
s.add_issue NamedRule.new, location: {2, 1},
|
||||
message: "Useless assignment", status: :disabled
|
||||
subject.catch(s).should be_valid
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ module Ameba::Rule::Lint
|
|||
s = Source.new %Q(
|
||||
a = 1 # ameba:disable #{NamedRule.name}
|
||||
)
|
||||
s.add_issue NamedRule.new, location: {2, 1},
|
||||
s.add_issue NamedRule.new, location: {1, 1},
|
||||
message: "Alarm!", status: :disabled
|
||||
subject.catch(s).should be_valid
|
||||
end
|
||||
|
@ -95,7 +95,7 @@ module Ameba::Rule::Lint
|
|||
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:9"
|
||||
issue.location.to_s.should eq "source.cr:1:1"
|
||||
issue.message.should eq "Unnecessary disabling of Rule1, Rule2"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -178,7 +178,7 @@ module Ameba::Rule::Lint
|
|||
issue.rule.should_not be_nil
|
||||
issue.message.should eq "Unused argument `a`. If it's necessary, use `_a` " \
|
||||
"as an argument name to indicate that it won't be used."
|
||||
issue.location.to_s.should eq "source.cr:2:22"
|
||||
issue.location.to_s.should eq "source.cr:1:12"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ module Ameba::Rule::Lint
|
|||
|
||||
issue = s.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:3:11"
|
||||
issue.location.to_s.should eq "source.cr:2:3"
|
||||
issue.message.should eq "Useless assignment to variable `a`"
|
||||
end
|
||||
|
||||
|
@ -137,7 +137,7 @@ module Ameba::Rule::Lint
|
|||
end
|
||||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
s.issues.first.location.to_s.should eq ":3:11"
|
||||
s.issues.first.location.to_s.should eq ":2:3"
|
||||
end
|
||||
|
||||
it "reports if variable reassigned and not used" do
|
||||
|
@ -316,7 +316,7 @@ module Ameba::Rule::Lint
|
|||
|
||||
issue = s.issues.last
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:5:13"
|
||||
issue.location.to_s.should eq "source.cr:4:3"
|
||||
issue.message.should eq "Useless assignment to variable `a`"
|
||||
end
|
||||
end
|
||||
|
@ -341,7 +341,7 @@ module Ameba::Rule::Lint
|
|||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
issue = s.issues.first
|
||||
issue.location.to_s.should eq ":3:16"
|
||||
issue.location.to_s.should eq ":2:6"
|
||||
issue.message.should eq "Useless assignment to variable `b`"
|
||||
end
|
||||
|
||||
|
@ -364,11 +364,11 @@ module Ameba::Rule::Lint
|
|||
subject.catch(s).should_not be_valid
|
||||
|
||||
issue = s.issues.first
|
||||
issue.location.to_s.should eq ":3:13"
|
||||
issue.location.to_s.should eq ":2:3"
|
||||
issue.message.should eq "Useless assignment to variable `a`"
|
||||
|
||||
issue = s.issues.last
|
||||
issue.location.to_s.should eq ":3:16"
|
||||
issue.location.to_s.should eq ":2:6"
|
||||
issue.message.should eq "Useless assignment to variable `b`"
|
||||
end
|
||||
end
|
||||
|
@ -381,8 +381,8 @@ module Ameba::Rule::Lint
|
|||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
s.issues.size.should eq 2
|
||||
s.issues.first.location.to_s.should eq ":2:11"
|
||||
s.issues.last.location.to_s.should eq ":3:11"
|
||||
s.issues.first.location.to_s.should eq ":1:1"
|
||||
s.issues.last.location.to_s.should eq ":2:1"
|
||||
end
|
||||
|
||||
it "doesn't report if assignments are referenced" do
|
||||
|
@ -445,7 +445,7 @@ module Ameba::Rule::Lint
|
|||
s.issues.size.should eq 1
|
||||
|
||||
issue = s.issues.first
|
||||
issue.location.to_s.should eq "source.cr:2:11"
|
||||
issue.location.to_s.should eq "source.cr:1:1"
|
||||
issue.message.should eq "Useless assignment to variable `foo`"
|
||||
end
|
||||
end
|
||||
|
@ -517,7 +517,7 @@ module Ameba::Rule::Lint
|
|||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
s.issues.size.should eq 1
|
||||
s.issues.first.location.to_s.should eq ":5:17"
|
||||
s.issues.first.location.to_s.should eq ":4:5"
|
||||
end
|
||||
|
||||
it "does not report of assignments are referenced in all branches" do
|
||||
|
@ -586,7 +586,7 @@ module Ameba::Rule::Lint
|
|||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
s.issues.size.should eq 1
|
||||
s.issues.first.location.to_s.should eq ":5:17"
|
||||
s.issues.first.location.to_s.should eq ":4:5"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -619,8 +619,8 @@ module Ameba::Rule::Lint
|
|||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
s.issues.size.should eq 2
|
||||
s.issues.first.location.to_s.should eq ":5:17"
|
||||
s.issues.last.location.to_s.should eq ":7:17"
|
||||
s.issues.first.location.to_s.should eq ":4:5"
|
||||
s.issues.last.location.to_s.should eq ":6:5"
|
||||
end
|
||||
|
||||
it "doesn't report if assignment is referenced in cond" do
|
||||
|
@ -656,7 +656,7 @@ module Ameba::Rule::Lint
|
|||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
s.issues.size.should eq 1
|
||||
s.issues.first.location.to_s.should eq ":3:27"
|
||||
s.issues.first.location.to_s.should eq ":2:15"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -683,7 +683,7 @@ module Ameba::Rule::Lint
|
|||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
s.issues.size.should eq 1
|
||||
s.issues.first.location.to_s.should eq ":4:17"
|
||||
s.issues.first.location.to_s.should eq ":3:5"
|
||||
end
|
||||
|
||||
it "does not report if assignment is referenced in a loop" do
|
||||
|
@ -778,7 +778,7 @@ module Ameba::Rule::Lint
|
|||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
s.issues.size.should eq 1
|
||||
s.issues.first.location.to_s.should eq ":4:17"
|
||||
s.issues.first.location.to_s.should eq ":3:5"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -826,7 +826,7 @@ module Ameba::Rule::Lint
|
|||
)
|
||||
subject.catch(s).should_not be_valid
|
||||
s.issues.size.should eq 1
|
||||
s.issues.first.location.to_s.should eq ":4:15"
|
||||
s.issues.first.location.to_s.should eq ":3:3"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ module Ameba::Rule::Lint
|
|||
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:6:23"
|
||||
issue.location.to_s.should eq "source.cr:5:15"
|
||||
issue.message.should eq "Useless condition in when detected"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue