{"id":23461,"library":"cppcheck-codequality","title":"cppcheck-codequality","description":"Convert a CppCheck XML report to a GitLab-compatible Code Quality JSON report. Version 1.6.0 supports Python 3.7 to 3.14. Releases are sporadic.","status":"active","version":"1.6.0","language":"python","source_language":"en","source_url":"https://github.com/GabrielGarv/cppcheck-codequality","tags":["cppcheck","code-quality","gitlab","report-conversion","static-analysis"],"install":[{"cmd":"pip install cppcheck-codequality","lang":"bash","label":"Stable release"}],"dependencies":[],"imports":[{"note":"The library provides a single `convert` function; import from `cppcheck_codequality` (with underscore), not from `cppcheck-codequality`.","wrong":null,"symbol":"convert","correct":"from cppcheck_codequality import convert"}],"quickstart":{"code":"import subprocess\nimport cppcheck_codequality\n\n# Run cppcheck and produce XML output\nwith open(\"cppcheck_report.xml\", \"r\") as f:\n    report_xml = f.read()\n\n# Convert to Code Quality JSON\njson_output = cppcheck_codequality.convert(report_xml)\nwith open(\"gl-code-quality-report.json\", \"w\") as f:\n    f.write(json_output)\n","lang":"python","description":"Read a CppCheck XML report file, convert to GitLab Code Quality JSON, and write to file."},"warnings":[{"fix":"Read the XML file contents into a string first using `open().read()`.","message":"The `convert` function expects a **string** containing XML, not a file path. Passing a file path will raise an error.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `json.loads(convert(xml_str))` to get a Python dict.","message":"The library output is a JSON string, not a Python dict. If you need to manipulate the report further, parse it with `json.loads(json_output)`.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to Python 3.9+ to ensure future compatibility.","message":"Support for Python 3.7 and 3.8 may be dropped in future releases. The current version requires Python >=3.7, <3.15.","severity":"deprecated","affected_versions":"1.6.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install cppcheck-codequality` and ensure no other package named `cppcheck_codequality` is interfering.","cause":"Installed package is `cppcheck-codequality` but import uses underscore; many users try `import cppcheck_codequality` which should work. This error may occur if the package is not installed or if there's a naming conflict.","error":"ImportError: No module named 'cppcheck_codequality'"},{"fix":"Read the file content first: `with open('report.xml') as f: xml = f.read(); convert(xml)`.","cause":"Passed a file path (string) instead of XML content to `convert()`.","error":"TypeError: expected string or bytes-like object"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}