def cppcheck(dsc, analysis): run_command(["dpkg-source", "-x", dsc, "source"]) with cd('source'): out, err, ret = run_command(['cppcheck', '--enable=all', '.', '--xml']) xmlbytes = err.encode() failed = False if err.strip() == '': return (analysis, err, failed) for issue in parse_cppcheck(xmlbytes): analysis.results.append(issue) if not failed and issue.severity in [ 'performance', 'portability', 'error', 'warning' ]: failed = True return (analysis, err, failed)
def cppcheck(dsc, analysis): run_command(["dpkg-source", "-x", dsc, "source"]) with cd('source'): out, err, ret = run_command([ 'cppcheck', '--enable=all', '.', '--xml' ]) xmlbytes = err.encode() failed = False if err.strip() == '': return (analysis, err, failed) for issue in parse_cppcheck(xmlbytes): analysis.results.append(issue) if not failed and issue.severity in [ 'performance', 'portability', 'error', 'warning' ]: failed = True return (analysis, err, failed)
def test_xml_parse(): for issue in parse_cppcheck(DATA): assert issue.testid == 'unusedFunction'