Class: Reporter::LintxmlReporter

Inherits:
Reporter
  • Object
show all
Defined in:
lib/scss_lint_reporter_lintxml.rb

Instance Method Summary collapse

Instance Method Details

#report_lintsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/scss_lint_reporter_lintxml.rb', line 3

def report_lints
  output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"

  output << "<lint>\n"
  lints.group_by(&:filename).each do |file_name, errors|
    output << "  <file name=#{file_name.encode(xml: :attr)}>\n"

    errors.each do |error|
      output << "    <issue source=\"#{error.linter.name if error.linter}\" " \
         "line=\"#{error.location.line}\" " \
         "char=\"#{error.location.column}\" " \
         #"length=\"#{error.location.length}\" " \
         "severity=\"#{error.severity}\" " \
         "reason=#{error.description.encode(xml: :attr)} />\n"
    end

    output << "  </issue>\n"
  end
  output << "</lint>\n"

  output
end