mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Track issue.end_location properly
This commit is contained in:
parent
ad2c6bad0e
commit
9885457227
45 changed files with 90 additions and 20 deletions
|
@ -27,6 +27,7 @@ module Ameba::Rule::Layout
|
|||
issue = source.issues.first
|
||||
issue.rule.should eq subject
|
||||
issue.location.to_s.should eq "source.cr:1:#{subject.max_length + 1}"
|
||||
issue.end_location.should be_nil
|
||||
issue.message.should eq "Line too long"
|
||||
end
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ module Ameba::Rule::Layout
|
|||
issue = source.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:3:1"
|
||||
issue.end_location.should be_nil
|
||||
issue.message.should eq "Blank lines detected at the end of the file"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,6 +21,7 @@ module Ameba::Rule::Layout
|
|||
issue = source.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:2:7"
|
||||
issue.end_location.should be_nil
|
||||
issue.message.should eq "Trailing whitespace detected"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -106,6 +106,7 @@ module Ameba::Rule::Lint
|
|||
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
|
||||
|
|
|
@ -38,6 +38,7 @@ module Ameba::Rule::Lint
|
|||
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
|
||||
|
|
|
@ -62,6 +62,7 @@ module Ameba::Rule::Lint
|
|||
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:2:3"
|
||||
issue.end_location.to_s.should eq "source.cr:6:3"
|
||||
issue.message.should eq "Empty `ensure` block detected"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -104,6 +104,7 @@ module Ameba
|
|||
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
|
||||
|
|
|
@ -35,6 +35,7 @@ module Ameba::Rule::Lint
|
|||
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
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ module Ameba::Rule::Lint
|
|||
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:20"
|
||||
issue.message.should eq "Literal value found in conditional"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,6 +35,7 @@ module Ameba::Rule::Lint
|
|||
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:6"
|
||||
issue.message.should eq "Literal value found in interpolation"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -61,6 +61,7 @@ module Ameba::Rule::Lint
|
|||
issue = s.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:1:1"
|
||||
issue.end_location.should be_nil
|
||||
issue.message.should eq(
|
||||
"Symbols `,\"` may be unwanted in %w array literals"
|
||||
)
|
||||
|
|
|
@ -30,6 +30,7 @@ module Ameba::Rule::Lint
|
|||
|
||||
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
|
||||
|
|
|
@ -159,6 +159,7 @@ module Ameba::Rule::Lint
|
|||
issue = s.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:2:3"
|
||||
issue.end_location.to_s.should eq "source.cr:2:10"
|
||||
issue.message.should eq "Argument `bar` is assigned before it is used"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -167,6 +167,7 @@ module Ameba::Rule::Lint
|
|||
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:2:3"
|
||||
issue.end_location.to_s.should eq "source.cr:4:3"
|
||||
issue.message.should eq(
|
||||
"Exception handler has shadowed exceptions: IndexError"
|
||||
)
|
||||
|
|
|
@ -161,6 +161,7 @@ module Ameba::Rule::Lint
|
|||
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
|
||||
end
|
||||
|
|
|
@ -682,5 +682,20 @@ module Ameba::Rule::Lint
|
|||
subject.catch(s).should be_valid
|
||||
end
|
||||
end
|
||||
|
||||
it "reports message, rule, location" do
|
||||
s = Source.new %(
|
||||
return
|
||||
:unreachable
|
||||
), "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:1"
|
||||
issue.end_location.to_s.should eq "source.cr:2:12"
|
||||
issue.message.should eq "Unreachable code detected"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,6 +39,7 @@ module Ameba::Rule::Lint
|
|||
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
|
||||
|
|
|
@ -43,6 +43,7 @@ module Ameba
|
|||
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:9"
|
||||
issue.message.should eq(
|
||||
"Constant name should be screaming-cased: CONST, not Const"
|
||||
)
|
||||
|
|
|
@ -118,6 +118,7 @@ module Ameba
|
|||
issue = s.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:1:1"
|
||||
issue.end_location.should be_nil
|
||||
issue.message.should match /1_200_000/
|
||||
end
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ module Ameba
|
|||
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:2:3"
|
||||
issue.message.should eq(
|
||||
"Method name should be underscore-cased: bad_name, not bad_Name"
|
||||
)
|
||||
|
|
|
@ -62,6 +62,7 @@ module Ameba::Rule::Style
|
|||
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:21"
|
||||
issue.message.should eq "Avoid negated conditions in unless blocks"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,6 +41,7 @@ module Ameba::Rule::Style
|
|||
issue = s.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:2:3"
|
||||
issue.end_location.to_s.should eq "source.cr:4:5"
|
||||
issue.message.should eq(
|
||||
"Favour method name 'picture?' over 'has_picture?'")
|
||||
end
|
||||
|
|
|
@ -220,6 +220,7 @@ module Ameba::Rule::Style
|
|||
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:7:3"
|
||||
issue.message.should eq "Redundant `begin` block detected"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -52,6 +52,7 @@ module Ameba
|
|||
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:2:3"
|
||||
issue.message.should eq(
|
||||
"Type name should be camelcased: MyClass, but it was My_class"
|
||||
)
|
||||
|
|
|
@ -38,6 +38,7 @@ module Ameba::Rule::Style
|
|||
issue.should_not be_nil
|
||||
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:5:3"
|
||||
issue.message.should eq "Favour if over unless with else"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,6 +53,7 @@ module Ameba
|
|||
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(
|
||||
"Var name should be underscore-cased: bad_name, not badName"
|
||||
)
|
||||
|
|
|
@ -36,6 +36,7 @@ module Ameba::Rule::Style
|
|||
|
||||
issue = source.issues.first
|
||||
issue.location.to_s.should eq "source.cr:2:1"
|
||||
issue.end_location.to_s.should eq "source.cr:5:3"
|
||||
issue.message.should eq "While statement using true literal as condition"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue