summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-04-01 08:54:22 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-04-01 08:54:22 +0000
commite3e13c45c7cf13c82f6fc62fa90dbf6b344505f7 (patch)
tree0330e61c97b28d01ce615706c915c069b2338724 /scripts
parentc2f146f0ad2eddc1b43e691ae1bc84bc37bdd1a0 (diff)
Add cpplint converter to cppcheck xml format
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/xunit@527 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 04682ff657c9a93e89d99b49a940de7f48f2afa5
Diffstat (limited to 'scripts')
-rw-r--r--scripts/cpplint_to_cppcheckxml.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/cpplint_to_cppcheckxml.py b/scripts/cpplint_to_cppcheckxml.py
new file mode 100644
index 00000000..e3a2d2de
--- /dev/null
+++ b/scripts/cpplint_to_cppcheckxml.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+
+# Convert output from Google's cpplint.py to the cppcheck XML format for
+# consumption by the Jenkins cppcheck plugin.
+
+# Reads from stdin and writes to stderr (to mimic cppcheck)
+
+
+import sys
+import re
+
+def cpplint_score_to_cppcheck_severity(score):
+ # I'm making this up
+ if score == 1:
+ return 'style'
+ elif score == 2:
+ return 'style'
+ elif score == 3:
+ return 'warning'
+ elif score == 4:
+ return 'warning'
+ elif score == 5:
+ return 'error'
+
+
+def parse():
+ # TODO: do this properly, using the xml module.
+ # Write header
+ sys.stderr.write('''<?xml version="1.0" encoding="UTF-8"?>\n''')
+ sys.stderr.write('''<results>\n''')
+
+ # Do line-by-line conversion
+ r = re.compile('([^:]*):([0-9]*): ([^\[]*)\[([^\]]*)\] \[([0-9]*)\].*')
+
+ for l in sys.stdin.readlines():
+ m = r.match(l.strip())
+ if not m:
+ continue
+ g = m.groups()
+ if len(g) != 5:
+ continue
+ fname, lineno, msg, label, score = g
+ severity = cpplint_score_to_cppcheck_severity(int(score))
+ sys.stderr.write('''<error file="%s" line="%s" id="%s" severity="%s" msg="%s"/>\n'''%(fname, lineno, label, severity, msg))
+
+ # Write footer
+ sys.stderr.write('''</results>\n''')
+
+
+if __name__ == '__main__':
+ parse()
+