Class: Formatter::Json

Inherits:
Object
  • Object
show all
Defined in:
lib/formatter/json.rb

Instance Method Summary collapse

Instance Method Details

#format(repo:, workflow_count:, findings:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/formatter/json.rb', line 5

def format(repo:, workflow_count:, findings:)
    summary = Finding::SEVERITIES.each_with_object({}) { |s, h|
        h[s.to_s] = findings.count { |f| f.severity == s }
    }

    JSON.pretty_generate({
        repo: repo,
        workflows: workflow_count,
        findings: findings.sort.map(&:to_h),
        summary: summary
    })
end