CodeQuality widget not visible in MR after using custom tool report

Aim: To get codequality widget in MR using the report generated from custom tool

Environment description

Gitlab enterprise edition 11.11.8-ee
Gitlab runner 11.9.x, shell executer
Project type: Android
Build: Gradle

Similar Issue

Followed guidelines:

  1. Code Quality | GitLab
  2. Code Quality | GitLab
  3. Files · master · James Heimbuck / JH_java_example_project · GitLab

Problem description

I don’t want to use codequality template ci.yml as mentioned on gitlab’s codequality link. Instead, I want that my custom-tool-produced report does the same job (get widget in MR discussion).

Steps

Code quality report is generated using sonarjava plugin of gradle and transformed to accepted json format as defined in custom tool section of codeQuality here.

The file is named gl-code-quality-report.json and is uploaded ok.
Snippet of .gitlab-ci.yml file that is responsible for stated problem:

 code_quality:
  stage: codereview

  script:
    - ./scripts/sonarScanner.sh (this produces the .json report in accepted format)

  artifacts:
    reports:
      codequality: gl-code-quality-report.json
    expire_in: 1 week
    paths:
      - gl-code-quality-report.json

Runner successfully executes the job, produces the .json report of the required format and uploads it. Block of artifact can be seen in the side column after the job finishes.

image

Sample issue block of the .json file:

    {
        "type": "issue",
        "fingerprint": "61a5aae5bb28f3cf4d51902645c73e43",
        "description": "Make this line start after 57 spaces to indent the code consistently.",
        "severity": "minor",
        "location": {
            "path": "app/src/main/java/com/xxx/yyy/SomeFile.java",
            "lines": {
                "begin": 59,
                "end": 59
            }
        }
    }

The report was generated for both the target branch and the source branch of the MR. This was very well pointed in many issues related to MR widget that reports are needed from both branches to have some comparison.

Observation

No block of codequality widget is seen in the MR discussion. Artifact can be downloaded and upon check can be seen to follow the required JSON format.

@shubh-agrawal Thanks for posting! The sonarjava plugin is available for Codeclimate and can be added to the codeclimate.yml file if you are using the GitLab template.

The rest of your setup looks like it should work without issue so the only other problem I can think of is the resulting file being too large to parse.

-James H - GitLab Product Manager