Class: ReportParser

Inherits:
Object
  • Object
show all
Defined in:
lib/resharper_inspectcode/report_parser.rb

Class Method Summary collapse

Class Method Details

.parse_report_xml(filepath) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/resharper_inspectcode/report_parser.rb', line 8

def self.parse_report_xml(filepath)
  xml_file = File.open(filepath)
  document = Oga.parse_xml(xml_file)
  issues = []
  document.xpath("//Report/Issues/Project").each do |project|
    project.children.each do |issue|
      next unless issue.kind_of?(Oga::XML::Element)

      file = issue.get("File").tr("\\", "/")
      offset = issue.get("Offset")
      line = (issue.get("Line") || "1").to_i
      message = issue.get("Message")
      issues << Issue.new(file, offset, line, message)
    end
  end
  return issues
end