Class: SentinelRb::Report::TableFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/sentinel_rb/report.rb

Overview

Table formatter for terminal output

Instance Method Summary collapse

Instance Method Details

#format(results, show_summary: true, colorize: true, **_options) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/sentinel_rb/report.rb', line 56

def format(results, show_summary: true, colorize: true, **_options)
  output = []

  if show_summary
    summary = SentinelRb::Analyzer.new.summarize_results(results)
    output << format_summary(summary, colorize)
    output << ""
  end

  results.each do |result|
    next if result[:findings].nil? || result[:findings].empty?

    output << format_file_header(result[:file], colorize)

    result[:findings].each do |finding|
      output << format_finding(finding, colorize)
    end

    output << ""
  end

  output.join("\n")
end