Add rule's name to flycheck formatter

This commit is contained in:
Vitalii Elenhaupt 2018-01-31 13:30:59 +02:00
parent 69cff77970
commit 2382657e15
No known key found for this signature in database
GPG key ID: 7558EF3A4056C706
2 changed files with 8 additions and 4 deletions

View file

@ -21,7 +21,9 @@ module Ameba::Formatter
s.error DummyRule.new, 1, 2, "message" s.error DummyRule.new, 1, 2, "message"
subject = flycheck subject = flycheck
subject.source_finished s subject.source_finished s
subject.output.to_s.should eq "source.cr:1:2: E: message\n" subject.output.to_s.should eq(
"source.cr:1:2: E: [#{DummyRule.name}] message\n"
)
end end
it "properly reports multi-line message" do it "properly reports multi-line message" do
@ -29,7 +31,9 @@ module Ameba::Formatter
s.error DummyRule.new, 1, 2, "multi\nline" s.error DummyRule.new, 1, 2, "multi\nline"
subject = flycheck subject = flycheck
subject.source_finished s subject.source_finished s
subject.output.to_s.should eq "source.cr:1:2: E: multi line\n" subject.output.to_s.should eq(
"source.cr:1:2: E: [#{DummyRule.name}] multi line\n"
)
end end
it "reports nothing if location was not set" do it "reports nothing if location was not set" do

View file

@ -4,9 +4,9 @@ module Ameba::Formatter
source.errors.each do |e| source.errors.each do |e|
next if e.disabled? next if e.disabled?
if loc = e.location if loc = e.location
output.printf "%s:%d:%d: %s: %s\n", output.printf "%s:%d:%d: %s: [%s] %s\n",
source.path, loc.line_number, loc.column_number, "E", source.path, loc.line_number, loc.column_number, "E",
e.message.gsub("\n", " ") e.rule.name, e.message.gsub("\n", " ")
end end
end end
end end