module SCSSLint
  # Reports lints in an XML format.
  class Reporter::XMLReporter < Reporter
    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.encode(xml: :attr)}>"

        file_lints.each do |lint|
          output << "<issue line=\"#{lint.location.line}\" " \
                           "column=\"#{lint.location.column}\" " \
                           "length=\"#{lint.location.length}\" " \
                           "severity=\"#{lint.severity}\" " \
                           "reason=#{lint.description.encode(xml: :attr)} />"
        end

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

      output
    end
  end
end

module SCSSLint
  # Reports lints in an XML format.
  class Reporter::XMLReporter < Reporter
    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.encode(xml: :attr)}>"

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

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

      output
    end
  end
end

Include linter name in XMLReporter
Include linter name in XMLReporter

Change-Id: I0c3ba513dbbd277fa1a1204b2257e7c20ff20d13
Reviewed-on: http://gerrit.causes.com/40810
Tested-by: jenkins <d95b56ce41a2e1ac4cecdd398defd7414407cc08@causes.com>
Reviewed-by: Shane da Silva <67fb7bfe39f841b16a1f86d3928acc568d12c716@brigade.com>
