11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/android_lint_translate_checkstyle_format/translate.rb', line 11
def trans(xml)
require 'rexml/document'
doc = REXML::Document.new
doc << REXML::XMLDecl.new('1.0', 'UTF-8')
checkstyle = doc.add_element("checkstyle")
issues = xml['issues']['issue'].is_a?(Array) ? xml['issues']['issue'] : [xml['issues']['issue']]
issues.each do |issue|
locations = issue['location'].is_a?(Array) ? issue['location'] : [issue['location']]
locations.each do |location|
file = checkstyle.add_element("file", {
'name' => location['@file']
})
file.add_element("error", {
'line' => location['@line'],
'severity' => issue['@severity'],
'message' => "[#{issue['@id']}] #{issue['@message']}\n #{issue['@explanation']}"
})
end
end
doc
end
|