Module: RailVerdict::FindingsCommand

Defined in:
lib/rail_verdict/findings_command.rb

Class Method Summary collapse

Class Method Details

.console(outcome) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/rail_verdict/findings_command.rb', line 14

def console(outcome)
  return "No findings.\n" if outcome.findings.empty?

  outcome.findings.sort_by(&:sort_key).map do |finding|
    location = finding.location
    line = location["start_line"] ? ":#{location['start_line']}" : ""
    "#{location.fetch('path')}#{line} [#{finding.severity}] #{finding.analyzer}/#{finding.rule_id}: #{finding.message}"
  end.join("\n") + "\n"
end

.document(outcome) ⇒ Object



7
8
9
10
11
12
# File 'lib/rail_verdict/findings_command.rb', line 7

def document(outcome)
  {
    "schema_version" => "1.0",
    "findings" => outcome.findings.sort_by(&:sort_key).map(&:to_schema_h)
  }
end