Class: HamlLint::Reporter::CheckstyleReporter

Inherits:
HamlLint::Reporter show all
Defined in:
lib/haml_lint/reporter/checkstyle_reporter.rb

Overview

Outputs report as an XML checkstyle document.

Instance Method Summary collapse

Methods inherited from HamlLint::Reporter

available, available?, cli_name, descendants, inherited, #initialize

Methods included from Hooks

#added_lint, #finished_file, #start

Constructor Details

This class inherits a constructor from HamlLint::Reporter

Instance Method Details

#display_report(report) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/haml_lint/reporter/checkstyle_reporter.rb', line 6

def display_report(report)
  lints = report.lints
  files = lints.group_by(&:filename)

  xml = '<?xml version="1.0" encoding="utf-8"?>'

  xml << '<checkstyle version="5.7">'

  files.each do |filename, offenses|
    xml << "<file name=\"#{filename}\">"
    xml << render_offenses(offenses)
    xml << '</file>'
  end

  xml << '</checkstyle>'
  log.log xml
end