项目作者: mmicu

项目描述 :
Merge XML files that use the cppcheck xml format.
高级语言: Python
项目地址: git://github.com/mmicu/merge-cppcheck-reports.git
创建时间: 2018-03-06T16:31:50Z
项目社区:https://github.com/mmicu/merge-cppcheck-reports

开源协议:MIT License

下载


merge-cppcheck-reports

This simple script merges XML files generated by cppcheck.

Usage

  1. $ python merge_cppcheck_reports.py -h
  2. usage: merge_cppcheck_reports.py [-h] [-r] file [file ...]
  3. Merge cppcheck XML reports.
  4. positional arguments:
  5. file list of XML files
  6. optional arguments:
  7. -h, --help show this help message and exit
  8. -r remove duplicates

Example

Considering the following two examples (examples/report_1.xml and examples/report_2.xml, respectively):

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <results version="2">
  3. <cppcheck version="1.82"></cppcheck>
  4. <errors>
  5. Checking main.c ...
  6. <error id="uninitvar" severity="error" msg="Uninitialized variable: p" verbose="Uninitialized variable: p" cwe="908">
  7. <location file="main.c" line="4"></location>
  8. </error>
  9. </errors>
  10. </results>
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <results version="2">
  3. <cppcheck version="1.82"></cppcheck>
  4. <errors>
  5. Checking main.c ...
  6. <error id="uninitvar" severity="error" msg="Uninitialized variable: p" verbose="Uninitialized variable: p" cwe="908">
  7. <location file="main.c" line="4"></location>
  8. </error>
  9. <error id="uninitvar" severity="error" msg="Uninitialized variable: p" verbose="Uninitialized variable: p2" cwe="908">
  10. <location file="main.c" line="5"></location>
  11. </error>
  12. </errors>
  13. </results>

The script produces the following two outputs (without options and using option -r, respectively):

  1. $ python merge_cppcheck_reports.py examples/report_1.xml examples/report_2.xml
  2. <results version="2">
  3. <cppcheck version="1.82" ></cppcheck>
  4. <errors>
  5. Checking main.c ...
  6. <error cwe="908" id="uninitvar" msg="Uninitialized variable: p" severity="error" verbose="Uninitialized variable: p">
  7. <location file="main.c" line="4" ></location>
  8. </error>
  9. <error cwe="908" id="uninitvar" msg="Uninitialized variable: p" severity="error" verbose="Uninitialized variable: p">
  10. <location file="main.c" line="4" ></location>
  11. </error>
  12. <error cwe="908" id="uninitvar" msg="Uninitialized variable: p" severity="error" verbose="Uninitialized variable: p2">
  13. <location file="main.c" line="5" ></location>
  14. </error>
  15. </errors>
  16. </results>
  1. $ python merge_cppcheck_reports.py examples/report_1.xml examples/report_2.xml -r
  2. <results version="2">
  3. <cppcheck version="1.82" ></cppcheck>
  4. <errors>
  5. Checking main.c ...
  6. <error cwe="908" id="uninitvar" msg="Uninitialized variable: p" severity="error" verbose="Uninitialized variable: p">
  7. <location file="main.c" line="4" ></location>
  8. </error>
  9. <error cwe="908" id="uninitvar" msg="Uninitialized variable: p" severity="error" verbose="Uninitialized variable: p2">
  10. <location file="main.c" line="5" ></location>
  11. </error>
  12. </errors>
  13. </results>