Skip to content

Fix code quality report display

LI Zhennan requested to merge nanmu42/gitlab:fix_codequality_issue_body into master

What does this MR do and why?

Pipeline code quality report fails to display when the severity field of the code climate artifact is missing. Since severity is an optional field in code climate spec, many linters(including golangci-lint) does not produce it. It may be an implementation flaw to assume the field always shows up.

Display of code quality severity icons is introduced in !46829 (diffs) and it handles the situation of missing severity field well. This bug is later introduced in !69917 (merged) .

Screenshots or screen recordings

A live example lies at https://gitlab.com/gitlab-org/cloud-native/gitlab-operator/-/pipelines/486724516/codequality_report

Before fix(screenshot taken from aforementioned URL):

image

After fix:

image

How to set up and validate locally

Firing up JDK and checkout into this branch, looks for a code quality report based on the artifact like this, where the severity field of each object is missing:

[
   {
      "description":"typecheck: too few arguments in call to NewBuilder",
      "fingerprint":"E57BB89E329D744235A5C9D2F52F7C39",
      "location":{
         "path":"helm/suite_test.go",
         "lines":{
            "begin":27
         }
      }
   },
   {
      "description":"goimports: File is not `goimports`-ed with -local gitlab.com/gitlab-org/cloud-native/gitlab-operator",
      "fingerprint":"9C7FBE39CE0764EB8D6C57AF8125408E",
      "location":{
         "path":"pkg/support/charts/catalog_test.go",
         "lines":{
            "begin":6
         }
      }
   }
]

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports