Skip to content

Commit

Permalink
Merge pull request #530 from crystal-ameba/fix-dot-formatter-failures…
Browse files Browse the repository at this point in the history
…-count
  • Loading branch information
Sija authored Dec 7, 2024
2 parents b8310b4 + 76c1120 commit 09b3a1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions spec/ameba/formatter/dot_formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ module Ameba::Formatter
output = IO::Memory.new
subject = DotFormatter.new output

before_each do
output.clear
end

describe "#started" do
it "writes started message" do
subject.started [Source.new ""]
Expand Down Expand Up @@ -51,7 +55,6 @@ module Ameba::Formatter
end

it "writes affected code by default" do
output.clear
s = Source.new(%(
a = 22
puts a
Expand All @@ -65,7 +68,6 @@ module Ameba::Formatter
end

it "writes severity" do
output.clear
s = Source.new(%(
a = 22
puts a
Expand All @@ -78,7 +80,6 @@ module Ameba::Formatter
end

it "doesn't write affected code if it is disabled" do
output.clear
s = Source.new(%(
a = 22
puts a
Expand All @@ -95,11 +96,14 @@ module Ameba::Formatter
end

it "does not write disabled issues" do
s = Source.new ""
s.add_issue(DummyRule.new, location: {1, 1},
message: "DummyRuleError", status: :disabled)
s = Source.new("").tap do |source|
source.add_issue(DummyRule.new, {1, 1}, "DummyRuleError", status: :disabled)
source.add_issue(NamedRule.new, {1, 2}, "NamedRuleError")
end
subject.finished [s]
output.to_s.should contain "1 inspected, 0 failures"
log = output.to_s
log.should_not contain "DummyRuleError"
log.should contain "1 inspected, 1 failure"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/ameba/formatter/dot_formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ module Ameba::Formatter

private def final_message(sources, failed_sources)
total = sources.size
failures = failed_sources.sum(&.issues.size)
failures = failed_sources.sum(&.issues.count(&.enabled?))
color = failures == 0 ? :green : :red
s = failures != 1 ? "s" : ""

Expand Down

0 comments on commit 09b3a1b

Please sign in to comment.