Class: PuppetLint::Report::CodeClimateReporter
- Inherits:
-
Object
- Object
- PuppetLint::Report::CodeClimateReporter
- Defined in:
- lib/puppet-lint/report/codeclimate.rb
Overview
Formats problems and writes them to a file as a code climate compatible report.
Class Method Summary collapse
Class Method Details
.write_report_file(problems, report_file) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/puppet-lint/report/codeclimate.rb', line 10 def self.write_report_file(problems, report_file) report = [] problems.each do || .each do || case [:kind] when :warning severity = 'minor' when :error severity = 'major' else next end issue = { type: :issue, check_name: [:check], description: [:message], categories: [:Style], severity: severity, location: { path: [:path], lines: { begin: [:line], end: [:line] } } } issue[:fingerprint] = Digest::MD5.hexdigest(Marshal.dump(issue)) if .key?(:description) && .key?(:help_uri) issue[:content] = "#{[:description].chomp('.')}. See [this page](#{[:help_uri]}) for more information about the `#{[:check]}` check." end report << issue end end File.write(report_file, "#{JSON.pretty_generate(report)}\n") end |