Sha256: 105d5b6824a1f2716cdbc5785484dcba92b5c7b37993a822270d45b896e1e645

Contents?: true

Size: 1.02 KB

Versions: 15

Compression:

Stored size: 1.02 KB

Contents

require 'csv'

class Brakeman::Report::CSV < Brakeman::Report::Base
  def generate_report
    headers = [
      "Confidence",
      "Warning Type",
      "File",
      "Line",
      "Message",
      "Code",
      "User Input",
      "Check Name",
      "Warning Code",
      "Fingerprint",
      "Link"
    ]

    rows = tracker.filtered_warnings.sort_by do |w|
      [w.confidence, w.warning_type, w.file, w.line || 0, w.fingerprint]
    end.map do |warning|
      generate_row(headers, warning)
    end

    table = CSV::Table.new(rows)

    table.to_csv
  end

  def generate_row headers, warning
    CSV::Row.new headers, warning_row(warning)
  end

  def warning_row warning
    [
      warning.confidence_name,
      warning.warning_type,
      warning_file(warning),
      warning.line,
      warning.message,
      warning.code && warning.format_code(false),
      warning.user_input && warning.format_user_input(false),
      warning.check_name,
      warning.warning_code,
      warning.fingerprint,
      warning.link,
    ]
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
brakeman-5.2.3 lib/brakeman/report/report_csv.rb
brakeman-lib-5.2.3 lib/brakeman/report/report_csv.rb
brakeman-min-5.2.3 lib/brakeman/report/report_csv.rb
brakeman-5.2.2 lib/brakeman/report/report_csv.rb
brakeman-lib-5.2.2 lib/brakeman/report/report_csv.rb
brakeman-min-5.2.2 lib/brakeman/report/report_csv.rb
brakeman-5.2.1 lib/brakeman/report/report_csv.rb
brakeman-lib-5.2.1 lib/brakeman/report/report_csv.rb
brakeman-min-5.2.1 lib/brakeman/report/report_csv.rb
brakeman-5.2.0 lib/brakeman/report/report_csv.rb
brakeman-lib-5.2.0 lib/brakeman/report/report_csv.rb
brakeman-min-5.2.0 lib/brakeman/report/report_csv.rb
brakeman-5.1.2 lib/brakeman/report/report_csv.rb
brakeman-lib-5.1.2 lib/brakeman/report/report_csv.rb
brakeman-min-5.1.2 lib/brakeman/report/report_csv.rb