mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Correct location name of reported issue
This commit is contained in:
parent
9fa13848bf
commit
799c0fd5e1
2 changed files with 4 additions and 7 deletions
|
@ -51,16 +51,14 @@ module Ameba::Rule::Performance
|
|||
|
||||
it "reports rule, pos and message" do
|
||||
s = Source.new %(
|
||||
File.read(path)
|
||||
.split("\n")
|
||||
.reject(&.empty?)
|
||||
.size
|
||||
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:9"
|
||||
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
|
||||
|
|
|
@ -32,7 +32,6 @@ module Ameba::Rule::Performance
|
|||
caller names (`select`/`reject` by default)."
|
||||
end
|
||||
|
||||
|
||||
def test(source)
|
||||
AST::NodeVisitor.new self, source
|
||||
end
|
||||
|
@ -43,7 +42,7 @@ module Ameba::Rule::Performance
|
|||
if obj.is_a?(Crystal::Call) &&
|
||||
object_call_names.includes?(obj.name) && !obj.block.nil?
|
||||
|
||||
issue_for obj, MSG % obj.name
|
||||
issue_for obj.name_location, node.name_end_location, MSG % obj.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue