class Nucop::Formatters::JUnitFormatter
Constants
- COPS
This gives all cops - we really want all enabled cops, but that is difficult to obtain - no access to config object here.
Public Instance Methods
file_finished(file, offences)
click to toggle source
# File lib/nucop/formatters/junit_formatter.rb, line 20 def file_finished(file, offences) # One test case per cop per file COPS.each do |cop| cop_offences = offences.select { |offence| offence.cop_name == cop.cop_name } next if cop_offences.empty? REXML::Element.new("testcase", @testsuite).tap do |f| f.attributes["classname"] = file.gsub(/\.rb\Z/, "").gsub("#{Dir.pwd}/", "").tr("/", ".") f.attributes["name"] = "Rubocop: #{cop.cop_name}" f.attributes["file"] = cop.cop_name cop_offences.each do |offence| REXML::Element.new("failure", f).tap do |e| e.add_text("#{offence.message}\n\n") e.add_text(offence.location.to_s.sub("/usr/src/app/", "")) end end end end end
finished(_inspected_files)
click to toggle source
# File lib/nucop/formatters/junit_formatter.rb, line 41 def finished(_inspected_files) @document.write(output, 2) end
started(_target_file)
click to toggle source
# File lib/nucop/formatters/junit_formatter.rb, line 10 def started(_target_file) @document = REXML::Document.new.tap do |d| d << REXML::XMLDecl.new end @testsuites = REXML::Element.new("testsuites", @document) @testsuite = REXML::Element.new("testsuite", @testsuites).tap do |el| el.add_attributes("name" => "rubocop") end end