Skip to content

Commit

Permalink
Merge pull request #122 from nevinera/nev--115--expose-parser-errors-…
Browse files Browse the repository at this point in the history
…through-logger

When brakeman produces errors, expose those errors (fixes #115)
  • Loading branch information
nevinera authored May 7, 2024
2 parents 22c4ec0 + 882c5f3 commit 9872051
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/quiet_quality/tools/brakeman/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module QuietQuality
module Tools
module Brakeman
class Parser
include Logging

def initialize(text)
@text = text
end
Expand All @@ -24,6 +26,8 @@ def data
def check_errors!
errors = data[:errors]
return if errors.nil? || errors.empty?
warn "Brakeman errors:"
errors.each { |error| warn " #{error}" }
fail(ParsingError, "Found #{errors.length} errors in brakeman output")
end

Expand Down
5 changes: 4 additions & 1 deletion spec/quiet_quality/tools/brakeman/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@
context "when there are errors" do
let(:text) { fixture_content("tools", "brakeman", "errors.json") }

it "raises a ParsingError" do
it "raises a ParsingError and logs the errors" do
expect { messages }.to raise_error(
QuietQuality::Tools::ParsingError,
/Found 2 errors/
)
expect_warn "Brakeman errors:"
expect_warn " Something went wrong"
expect_warn " Something else too"
end
end
end
Expand Down

0 comments on commit 9872051

Please sign in to comment.