Code Quality Widget not showing number of changes

  • Describe your question in as much detail as possible:

How do I get the number of improvements/degredations to appear in the Code Quality widget? I’m wondering if GitLab recently redesigned the Code Quality widget (and perhaps their docs are out-of-date)


  • What are you seeing, and how does that differ from what you expect to see?

The Code Quality widget only says whether code quality improved or degraded, but not the number of points.

I expect to see the number of improvements/degredations. The following is a screenshot from GitLab Docs | Code Quality:

image


  • What version are you on? Are you using self-managed or GitLab.com?

GitLab SaaS 14.7.3


  • Add the CI configuration from .gitlab-ci.yml and other configuration if relevant (e.g. docker-compose.yml)

For testing purposes, I used a hardcoded “dummy” code quality report with the following CI/CD configuration:

code_quality:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script:
    - cat gl-code-quality-report.json
  artifacts:
    reports:
      codequality: gl-code-quality-report.json

Here is the code quality report:

[
  {
    "description": "Bad spelling",
    "fingerprint": "123",
    "severity": "major",
    "location": {
      "path": "src/Program.cs",
      "lines": {
        "begin": 1
      }
    }
  }
]

  • What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?

I’ve tried manipulating the code quality report by: adding additional violations, removing violations, creating dummy merge requests, etc.

I was able to answer this myself:

When merged, gitlab-org/gitlab#244338 changed code quality widget text.

The original behavior is being discussed at gitlab-org/gitlab#337798.

Is this still opened? I’m using GitLab Enterprise Edition v16.0.5-ee and I’m having an issue in a MR, where the widget states there are no changes but If I download the report I can see a number of violations. Also, despite the fact it succeed, if I tap on the Code Quality tab Im getting Failed to load Code Quality report.

Here is my setup

code-quality:
  variables:
    CODE_CLIMATE_REPORT_PATH: "reports/lint/lint_report.json"
  stage: quality
  rules:
    - !reference [.master_rules, rules]
  artifacts:
    paths:
      - "$CODE_CLIMATE_REPORT_PATH"
    reports:
      codequality: "$CODE_CLIMATE_REPORT_PATH"
  script:
    - bundle exec fastlane run_lint
  tags:
    - macos
  interruptible: true
swiftlint(
      mode: :lint,
      output_file: "reports/lint/lint_report.json",
      reporter: "codeclimate", 
      config_file: ".swiftlint.yml",
      raise_if_swiftlint_error: true,
    )

I opened my web inspector and it seems the report fails to load when pointing to api/graphql with the following error.

{
  "errors": [
    {
      "message": "Unexpected end of document",
      "locations": []
    }
  ]
}