Skip to content

Instantly share code, notes, and snippets.

@nazo
Created April 26, 2016 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nazo/0f1c4ca357122b2d0cbcc3623df76d1a to your computer and use it in GitHub Desktop.
Save nazo/0f1c4ca357122b2d0cbcc3623df76d1a to your computer and use it in GitHub Desktop.
gcc brief format to checkstyle report xml
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