Class: HamlLint::Reporter::JsonReporter

Inherits:
HamlLint::Reporter show all
Defined in:
lib/haml_lint/reporter/json_reporter.rb

Overview

Outputs report as a JSON document.

Instance Method Summary collapse

Methods inherited from HamlLint::Reporter

descendants, inherited, #initialize

Constructor Details

This class inherits a constructor from HamlLint::Reporter

Instance Method Details

#display_report(report) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/haml_lint/reporter/json_reporter.rb', line 4

def display_report(report)
  lints = report.lints
  grouped = lints.group_by(&:filename)

  report_hash = {
    metadata: ,
    files: grouped.map { |l| map_file(l) },
    summary: {
      offense_count: lints.length,
      target_file_count: grouped.length,
      inspected_file_count: report.files.length,
    },
  }

  log.log report_hash.to_json
end