class RuboCop::Formatter::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/rubocop/formatter/junit_formatter.rb, line 21 def file_finished(file, offences) # One test case per cop per file COPS.each do |cop| REXML::Element.new('testcase', @testsuite).tap do |f| f.attributes['classname'] = file.gsub(/\.rb\Z/, '').gsub("#{Dir.pwd}/", '').gsub('/', '.') f.attributes['name'] = cop.cop_name # One failure per offence. Zero failures is a passing test case, # for most surefire/nUnit parsers. offences.select {|offence| offence.cop_name == cop.cop_name}.each do |offence| REXML::Element.new('failure', f).tap do |e| e.attributes['type'] = cop.cop_name e.attributes['message'] = offence.message e.add_text offence.location.to_s end end end end end
finished(inspected_files)
click to toggle source
# File lib/rubocop/formatter/junit_formatter.rb, line 41 def finished(inspected_files) @document.write(output, 2) end
started(target_file)
click to toggle source
# File lib/rubocop/formatter/junit_formatter.rb, line 11 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