Handle non-standard severities better in codequality degradations
What does this MR do and why?
This merge request updates CodequalityDegradationEntity
serializer to handle non-codeclimate-standard severities better to fix issues where some external linting tools (e.g. golanglint-ci
) might produce a report of degradations in codeclimate
format but still use severities such as warning
.
There are five severities that are standardized in CodeClimate: blocker
, critical
, major
, minor
, issue
, and we also add unknown
to the list when sorting degradations by their severity, so when a report contains a degradation with such non-standard severity, we run into issues with displaying that information in a merge request changes tab.
See this issue and comment for more information.
Resolves #440246 (closed).
MR acceptance checklist
I have evaluated this MR against the MR acceptance checklist.
How to set up and validate locally
- On your local GDK, create a new project.
- In the new project, add a
.gitlab-ci.yml
file with the following content:
include:
- template: Code-Quality.gitlab-ci.yml
lint:
stage: test
image: golangci/golangci-lint:v1.55.2
script:
- golangci-lint run --issues-exit-code 0 --print-issued-lines=false --out-format code-climate:gl-code-quality-report.json,line-number
- Add some
golang
code with a few linting issues. - Run a new pipeline.
- Notice how the
gl-code-quality-report.json
file generated bygolangci-lint
includes some degradations withwarning
severity. - Open a merge request to update the
golang
code you have added previously. - Validate the merge request changes tab located at
merge_requests/:id/-/diffs
load degradations successfully.