Created
April 26, 2016 04:04
-
-
Save nazo/0f1c4ca357122b2d0cbcc3623df76d1a to your computer and use it in GitHub Desktop.
gcc brief format to checkstyle report xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read() | |
files = {} | |
while line = STDIN.gets | |
if /^([^:]*):([0-9]+):([0-9]+): *(.*)$/ =~ line | |
filename, line, column, message = $1, $2, $3, $4 | |
if !files.has_key?(filename) | |
files[filename] = [] | |
end | |
files[filename].push({:line => line, :column => column, :message => message}) | |
end | |
end | |
files | |
end | |
files = read() | |
print "<?xml version='1.0'?>\n" | |
print "<checkstyle>\n" | |
files.each do |filename, errors| | |
printf "<file name='%s'>\n", filename | |
errors.each do |error| | |
printf "<error line='%d' column='%d' severity='info' message='%s' />\n", error[:line], error[:column], error[:message] | |
end | |
print "</file>\n" | |
end | |
print "</checkstyle>\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment