Skip to content

Commit

Permalink
Add rule's name to flycheck formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
veelenga committed Jan 31, 2018
1 parent 69cff77 commit 2382657
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions spec/ameba/formatter/flycheck_formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ module Ameba::Formatter
s.error DummyRule.new, 1, 2, "message"
subject = flycheck
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

it "properly reports multi-line message" do
s = Source.new "a = 1", "source.cr"
s.error DummyRule.new, 1, 2, "multi\nline"
subject = flycheck
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

it "reports nothing if location was not set" do
Expand Down
4 changes: 2 additions & 2 deletions src/ameba/formatter/flycheck_formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module Ameba::Formatter
source.errors.each do |e|
next if e.disabled?
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",
e.message.gsub("\n", " ")
e.rule.name, e.message.gsub("\n", " ")
end
end
end
Expand Down

0 comments on commit 2382657

Please sign in to comment.