Correct location name of reported issue

This commit is contained in:
Vitalii Elenhaupt 2018-09-03 13:25:32 +03:00
parent 9fa13848bf
commit 799c0fd5e1
No known key found for this signature in database
GPG key ID: 7558EF3A4056C706
2 changed files with 4 additions and 7 deletions

View file

@ -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

View file

@ -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