sonar-gitlab-plugin
sonar-gitlab-plugin copied to clipboard
Generated JSON files are not displayed correctly in GitLab
Hi,
I'm having an issue when using the plugin with GitLab (10.8.4-ee) and SonarQube 6.7.4 LTS. I'm using the plugin pretty much as the README suggests with the .gitlab-ci.yml
.
The problem is the code quality results are not displayed correctly as shown below:
So the actual error description is missing from the MR view.
I have also tried to use the SAST instead of codeclimate. When using that one I'm getting the result below:
On the comments the plugin is posting the issues correctly and the inline commenting works as well. My guess is that the JSON format is not what the GitLab is expecting in either one. Or am I doing something wrong?
Hi, Do you send json ? Thanks
Hello,
We're running: GitLab Enterprise Edition 11.2.3-ee Plugin: 4.0 Sonarqube: 7.0
I have the same issue, here's the generated file:
[
{
"fingerprint": "01663BAC7E3FC31BF0",
"check_name": "Add a default case to this switch.",
"location": {
"path": "backend/src/main/java/com/foobar/ccap/CcapApplication.java",
"lines": {
"begin": 10,
"end": 10
}
}
},
{
"fingerprint": "01663BAC7E3FC31BF2",
"check_name": "Replace this use of System.out or System.err by a logger.",
"location": {
"path": "backend/src/main/java/com/foobar/ccap/CcapApplication.java",
"lines": {
"begin": 12,
"end": 12
}
}
},
{
"fingerprint": "01663BAC7E3FC31BF3",
"check_name": "Replace this use of System.out or System.err by a logger.",
"location": {
"path": "backend/src/main/java/com/foobar/ccap/CcapApplication.java",
"lines": {
"begin": 15,
"end": 15
}
}
},
{
"fingerprint": "01663BAC7E3FC31BF1",
"check_name": "Replace this \"switch\" statement by \"if\" statements to increase readability.",
"location": {
"path": "backend/src/main/java/com/foobar/ccap/CcapApplication.java",
"lines": {
"begin": 10,
"end": 10
}
}
}
]
In my setup above i'm renaming the generated codeclimate.json
to gl-code-quality-report.json
according to the change https://gitlab.com/gitlab-org/gitlab-ee/issues/5779
Maybe it still works with legacy format if I would use the old codeclimate job and filename?
If I remember correctly I tried it with both filenames, but with the other GitLab did not even try to show the results. I'm afraid I don't have the file at hand anymore.
I can confirm this issue (sonar version 6.7.3 LTS
, plugin version 3.0.2
) and it's a blocker moving ahead for me! Also see #192, seems related to this one.
I ran both sonarqube
and codeclimate
quality checks on my local code and see major differences in the reported json
file.
-
@jacobk is correct, renaming the file from
codeclimate.json
togl-code-quality-report.json
is required, I've usedafter-script: ...
in GitLab for that. -
Compare the
codeclimate
andsonarqube
reports below. The sonarqube one is serving a different structure. I assume behaviour will be very similar inCODECLIMATE
andSAST
reports.
// sonarqube result structure:
{
"check_name": "Method `helloworld` has 30 lines of code (exceeds 25 allowed). Consider refactoring.",
"fingerprint": "AWc12WmckbqUmfOKZo1t",
"location": {
"lines": {
"begin": 71,
"end": 107
},
"path": "src/test/java/com/aaa/bbb/greeting.java"
}
},
// codeclimate result structure:
{
"categories": [
"Complexity"
],
"check_name": "method_lines",
"content": {
"body": ""
},
"description": "Method `helloworld` has 30 lines of code (exceeds 25 allowed). Consider refactoring.",
"engine_name": "structure",
"fingerprint": "4f1f05758e73e8ab1e0afb3cc5119ab7",
"location": {
"lines": {
"begin": 71,
"end": 107
},
"path": "src/test/java/com/aaa/bbb/greeting.java"
},
"other_locations": [],
"remediation_points": 720000,
"severity": "minor",
"type": "issue"
},
@gabrie-allaigre, @tuomoa i'm happy to support resolving this.