Class: LintTrappings::Formatter::Checkstyle
- Defined in:
- lib/lint_trappings/formatter/checkstyle.rb
Overview
Outputs results in a Checkstyle-compatible format.
Instance Method Summary collapse
Methods inherited from Base
#initialize, #job_finished, #job_started, #started
Constructor Details
This class inherits a constructor from LintTrappings::Formatter::Base
Instance Method Details
#finished(report) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lint_trappings/formatter/checkstyle.rb', line 9 def finished(report) xml = StringIO.new xml << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" xml << "<checkstyle version=\"1.5.6\">\n" report.lints.group_by(&:path).each do |path, lints| file_name_absolute = File.(path) xml << " <file name=#{file_name_absolute.encode(xml: :attr)}>\n" lints.each do |lint| xml << " <error source=\"#{lint.linter.canonical_name if lint.linter}\" " \ "line=\"#{lint.location.line}\" " \ "column=\"#{lint.location.column}\" " \ "length=\"#{lint.location.length}\" " \ "severity=\"#{lint.severity}\" " \ "message=#{lint..encode(xml: :attr)} />\n" end xml << " </file>\n" end xml << "</checkstyle>\n" output.print xml.string end |