Class: SCSSLint::Reporter::XMLReporter

Inherits:
SCSSLint::Reporter show all
Defined in:
lib/scss_lint/reporter/xml_reporter.rb

Overview

Reports lints in an XML format.

Instance Attribute Summary

Attributes inherited from SCSSLint::Reporter

#lints

Instance Method Summary collapse

Methods inherited from SCSSLint::Reporter

#initialize

Constructor Details

This class inherits a constructor from SCSSLint::Reporter

Instance Method Details

#report_lintsObject


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

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

  output << '<lint>'
  lints.group_by(&:filename).each do |filename, file_lints|
    output << "<file name='#{filename}'>"

    file_lints.each do |lint|
      output << "<issue line='#{lint.line}' " <<
                       "severity='#{lint.severity}' " <<
                       "reason='#{lint.description}' />"
    end

    output << '</file>'
  end
  output << '</lint>'

  output
end