[Pkg-debile-commits] [debile-slave] 15/100: add cppcheck
Sylvestre Ledru
sylvestre at alioth.debian.org
Mon Aug 19 14:53:00 UTC 2013
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch master
in repository debile-slave.
commit 2d8e4b8b155c28ed1a981ac7a465ab7318658ed0
Author: Paul Tagliamonte <tag at pault.ag>
Date: Fri May 24 21:48:54 2013 -0400
add cppcheck
---
ethel/wrappers/cppcheck.py | 27 +++++++++++++++++++++++++++
tests/wrappers/test_cppcheck.py | 32 ++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/ethel/wrappers/cppcheck.py b/ethel/wrappers/cppcheck.py
new file mode 100644
index 0000000..bb1a085
--- /dev/null
+++ b/ethel/wrappers/cppcheck.py
@@ -0,0 +1,27 @@
+from firehose.model import Issue, Message, File, Location, Point
+import lxml.etree
+
+
+def parse_cppcheck_xml(payload):
+ tree = lxml.etree.fromstring(payload)
+ for result in tree.xpath("//results/error"):
+
+ if 'file' not in result.attrib:
+ continue
+
+ path = result.attrib['file']
+ line = result.attrib['line']
+ severity = result.attrib['severity']
+ message = result.attrib['msg']
+ testid = result.attrib['id']
+
+ yield Issue(cwe=None,
+ testid=testid,
+ location=Location(
+ file=File(path, None),
+ function=None,
+ point=Point(int(line), 0) if line else None),
+ severity=severity,
+ message=Message(text=message),
+ notes=None,
+ trace=None)
diff --git a/tests/wrappers/test_cppcheck.py b/tests/wrappers/test_cppcheck.py
new file mode 100644
index 0000000..c0d4778
--- /dev/null
+++ b/tests/wrappers/test_cppcheck.py
@@ -0,0 +1,32 @@
+from ethel.wrappers.cppcheck import parse_cppcheck_xml
+
+DATA = b"""<?xml version="1.0" encoding="UTF-8"?>
+<results>
+ <error file="src/tmperamental.c" line="91" id="unusedFunction"
+ severity="style" msg="The function 'creat' is never used."/>
+
+ <error file="src/tmperamental.c" line="97" id="unusedFunction"
+ severity="style" msg="The function 'fopen' is never used."/>
+
+ <error file="src/tmperamental.c" line="103" id="unusedFunction"
+ severity="style" msg="The function 'freopen' is never used."/>
+
+ <error file="src/tmperamental.c" line="85" id="unusedFunction"
+ severity="style" msg="The function 'mkdir' is never used."/>
+
+ <error file="src/tmperamental.c" line="70" id="unusedFunction"
+ severity="style" msg="The function 'open' is never used."/>
+
+ <error file="src/tmperamental.c" line="48" id="unusedFunction"
+ severity="style"
+ msg="The function 'tmperamental_init' is never used."/>
+
+ <error id="missingInclude" severity="style"
+ msg="Cppcheck cannot find all the include files (use --check-config for details)"/>
+</results>
+"""
+
+
+def test_xml_parse():
+ for issue in parse_cppcheck_xml(DATA):
+ assert issue.testid == 'unusedFunction'
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-slave.git
More information about the Pkg-debile-commits
mailing list