Skip to main content

cppcheck-codequality

badge-pypi   badge-pypi-downloads

badge-pipeline   badge-coverage   badge-pylint   badge-formatting   badge-issues-cnt

About

I wanted reports from CppCheck to appear in GitLab Merge Requests as Code Quality reports, which is a JSON file defined by the Code Climate team/service.

That's all this does: convert CppCheck XML to Code Climate JSON.

Usage

It is primarily used as a console script. As such, ensure you have Python 3's "scripts" directory in your PATH variable. For example, on Linux, that might be $HOME/.local/bin.

To test, try the --help or --version flags:

cppcheck-codequality --help

CppCheck already has a script to convert its XML report to HTML for easy human reading. See "Chapter 11 HTML Report" in the CppCheck Manual

This script follows that example and provides similar command-line options. A typical workflow might look like this:

# Generate CppCheck report as XML
cppcheck --xml --enable=warning,style,performance ./my_src_dir/ 2> cppcheck_out.xml
# Convert to a Code Climate JSON report
cppcheck-codequality --input-file cppcheck_out.xml --output-file cppcheck.json

If you wanted, you could invoke the script directly as a module, like this:

# Run as a module instead (note the underscore in the module name here)
python -m cppcheck_codequality --input-file=cppcheck_out.xml --output-file=cppcheck.json

Now, in your GitLab CI script, upload this file as a Code Quality report.

my-code-quality:
  script:
    - [...]
  artifacts:
    reports:
      codequality: cppcheck.json

Contributing

  • Format with black
  • Check with pylint
  • Run tests
  • Signoff commits (git commit -s) to indicate you agree to Developer Certificate of Origin (DCO) Version 1.1 https://developercertificate.org/
  • Create a GitLab merge request and I'll take a look!

Details

Setup development environment.

sudo apt install pipx
pipx install poetry
poetry install
source ./venv/bin/activate

Format

black ./

Use Tox to run tests in all python environments available on your system.

poetry run tox -e clean
poetry run tox

Credits & Trademarks

CppCheck is an open-source project with a GPL v3.0 license.

"Code Climate" may be a registered trademark of Code Climate, Inc. which provides super-cool free and paid services to the developer community.

"GitLab" is a trademark of GitLab B.V.

All other trademarks belong to their respective owners.

Release files for cppcheck-codequality 1.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cppcheck-codequality 1.6.0
File Size Uploaded
cppcheck_codequality-1.6.0.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cppcheck-codequality 1.6.0
File Interpreter ABI Platform
cppcheck_codequality-1.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.6 kB

Release files / cppcheck_codequality-1.6.0.tar.gz

Download URL cppcheck_codequality-1.6.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
88ecf0f77484b7cfced3a54d2b1a07c00e8f45bce37826c4ab8b52ae3ef71a26
BLAKE2b-256 checksum
How to use checksums
8e967bfb4533b7e319370059bb0026d2319da180a3b6ed324142233d9e67e8cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.7.17 Linux/5.15.154+

Release files / cppcheck_codequality-1.6.0-py3-none-any.whl

Download URL cppcheck_codequality-1.6.0-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
035feee470bf707b079a65677bf7e2aa77fc6e9d7ede687b8193481f4ba124bc
BLAKE2b-256 checksum
How to use checksums
fef75ae4ad53ad1d2a7ce4e4ac77ffad1b16e594277eec64905e4a2bb0b21590
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.7.17 Linux/5.15.154+

Release history Release notifications | RSS feed

This release

1.6.0 This release

2 release files

1.5.0

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page