Class: WhyClasses::Formatters::JsonFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/why_classes/formatters/json_formatter.rb

Overview

Machine-readable output (editors, LSP bridges, CI dashboards).

Instance Method Summary collapse

Methods inherited from BaseFormatter

#initialize

Constructor Details

This class inherits a constructor from WhyClasses::Formatters::BaseFormatter

Instance Method Details

#call(reports) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/why_classes/formatters/json_formatter.rb', line 10

def call(reports)
  payload = {
    "summary" => {
      "files_inspected" => reports.size,
      "offenses" => total_offenses(reports),
      "corrected" => total_corrected(reports)
    },
    "files" => reports.map { |report| file_payload(report) }
  }
  io.puts JSON.pretty_generate(payload)
end