Add severity to formatters

This commit is contained in:
Vitalii Elenhaupt 2019-04-14 16:45:31 +03:00
parent 575fe07879
commit 117e100855
No known key found for this signature in database
GPG key ID: 7558EF3A4056C706
11 changed files with 73 additions and 6 deletions

View file

@ -64,6 +64,19 @@ module Ameba::Formatter
log.should contain " \e[33m^\e[0m"
end
it "writes severity" do
output.clear
s = Source.new(%(
a = 22
puts a
)).tap do |source|
source.add_issue(DummyRule.new, {1, 5}, "DummyRuleError")
end
subject.finished [s]
log = output.to_s
log.should contain "[R]"
end
it "doesn't write affected code if it is disabled" do
output.clear
s = Source.new(%(

View file

@ -50,6 +50,7 @@ module Ameba
source = Source.new "a = 42", "source.cr"
output = explanation(source)
output.should contain "RULE INFO"
output.should contain "Refactoring"
output.should contain "Ameba/ErrorRule"
output.should contain "Always adds an error at 1:1"
end

View file

@ -22,7 +22,7 @@ module Ameba::Formatter
subject = flycheck
subject.source_finished s
subject.output.to_s.should eq(
"source.cr:1:2: E: [#{DummyRule.rule_name}] message\n"
"source.cr:1:2: R: [#{DummyRule.rule_name}] message\n"
)
end
@ -32,7 +32,7 @@ module Ameba::Formatter
subject = flycheck
subject.source_finished s
subject.output.to_s.should eq(
"source.cr:1:2: E: [#{DummyRule.rule_name}] multi line\n"
"source.cr:1:2: R: [#{DummyRule.rule_name}] multi line\n"
)
end

View file

@ -37,6 +37,14 @@ module Ameba
result["sources"][0]["issues"][0]["rule_name"].should eq DummyRule.rule_name
end
it "shows severity" do
s = Source.new ""
s.add_issue DummyRule.new, {1, 2}, "message"
result = get_result [s]
result["sources"][0]["issues"][0]["severity"].should eq "Refactoring"
end
it "shows a message" do
s = Source.new ""
s.add_issue DummyRule.new, {1, 2}, "message"

View file

@ -43,6 +43,10 @@ module Ameba
create_todo.should contain "DummyRule"
end
it "creates a todo with severity" do
create_todo.should contain "Refactoring"
end
it "creates a todo with problems count" do
create_todo.should contain "Problems found: 1"
end