Repository navigation
Add gitlab code quality report format - #9076
Open
comkieffer wants to merge 3 commits into
Open
comkieffer wants to merge 3 commits into
comkieffer wants to merge 3 commits into
Conversation
Add --output-format=gitlab-codequality, which writes findings as a GitLab Code Quality JSON array. Findings without a source location are skipped because GitLab requires a location. The existing warning hash is used as the fingerprint, with a location-based fallback when no token hash is available.
Track whether the GitLab Code Quality report contains an absolute location. Warn on stdout so the JSON report on stderr stays valid, even when --relative-paths was given but did not make the path relative.
Append the CWE ID to the finding description when available, matching the output of cppcheck-codequality.
Contributor
|
There should probably be a trac ticket for this PR. Please create it, or ask us to create it. Then the PR title should be updated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a Gitlab Code Quality result format.
Gitlab SARIF reports are reserved for Ultimate subscriptions (not just Premium). The option so far has been to generate an xml report, and use cppcheck-codequality to convert that xml in the JSON CodeClimate format used by the Gitlab Code Quality feature.
This pull-request adds a native Gitlab Code Quality format to cppcheck.
It adds a
gitlab-codequalityoption to the--output-formatCLI option, and follows the same logic as the SARIF report. The Code Quality report is a lot more limited than the SARIF repoort though, so the feature is quite a bit simpler.The main logic deviation between the two is that Gitlab require repository-relative paths for files. We can't check for that in cppcheck, but we can at least check that there are no absolute paths in the report.
Test it with:
cppcheck \ --enable=warning,style,performance \ --output-format=gitlab-codequality \ --relative-paths="$PWD" \ --output-file=gl-code-quality-report.json \ srcAs a sanity check of the output, I compared the new JSON with the output of
cppcheck-codequalityand they are identical, except for thefingerprintfield. This implementation uses the finding hash, wherecppcheck-codequalitycomputed it's own hash.