Correct trailing blank line position

This commit is contained in:
Vitalii Elenhaupt 2018-12-24 00:44:15 +02:00
parent 1d96319506
commit 32ac199162
No known key found for this signature in database
GPG key ID: 7558EF3A4056C706
2 changed files with 2 additions and 2 deletions

View file

@ -30,7 +30,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.location.to_s.should eq "source.cr:2:1"
issue.end_location.should be_nil
issue.message.should eq "Blank lines detected at the end of the file"
end

View file

@ -17,7 +17,7 @@ module Ameba::Rule::Layout
def test(source)
if source.lines.size > 1 && source.lines[-2, 2].join.strip.empty?
issue_for({source.lines.size, 1}, MSG)
issue_for({source.lines.size - 1, 1}, MSG)
end
end
end