Class: LintTrappings::Formatter::JSON
- Defined in:
- lib/lint_trappings/formatter/json.rb
Overview
Outputs report as a JSON document.
Instance Method Summary collapse
Methods inherited from Base
#initialize, #job_finished, #job_started, #started
Constructor Details
This class inherits a constructor from LintTrappings::Formatter::Base
Instance Method Details
#finished(report) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lint_trappings/formatter/json.rb', line 7 def finished(report) lints = report.lints grouped = lints.group_by(&:path) report_hash = { metadata: , files: grouped.map { |path, lints_for_path| path_hash(path, lints_for_path) }, summary: { offense_count: lints.count, offending_file_count: grouped.count, inspected_file_count: report.documents_inspected.count, }, } output.puts ::JSON.pretty_generate(report_hash) end |