A pull request analysis reports duplicated code and the corresponding quality gate fails because of the new_duplicated_lines_density condition. However, SonarQube does not create any pull-request decoration on the corresponding pull request.
Steps to reproduce:
Create a pull request containing duplicated C++ code.
Run the SonarQube pull request analysis.
Confirm that the analysis reports a non-compliant new_duplicated_lines_density value.
Confirm that the SonarQube quality gate fails.
Check the pull request in the connected DevOps platform.
Actual behavior:
The quality gate fails in SonarQube, but no PR decoration is posted.
Expected behavior:
The pull request should receive the SonarQube quality-gate decoration and indicate that the quality gate failed because of the duplication condition. The decoration should also provide a link to the SonarQube analysis, where the duplicated-code details can be reviewed. The decoration issue should be at the duplicate lines.
Impact:
Developers cannot see the failed quality gate directly in the pull request and may incorrectly assume that the analysis failed due to infrastructure reasons.
Hey @KUGA2, are other PRs successfully decorated (for example when the Quality Gate fails on a different condition or passes entirely)? Could you check for any warnings or errors related to PR decoration/Azure DevOps integration around that background task in your server logs (main log file to check should be ce.log)? If you don’t see anything relevant, perhaps you could try setting the instance’s log level to DEBUG and reproducing the issue (remember to set it back to INFO after you’re done).
Yes. Regular SQ issues (like wrong function name) appear.
In my reproduction, where I only added the duplication, the analysis is SUCCESSFUL.
16:09:54.065 INFO ANALYSIS SUCCESSFUL, you can find the results at: https://sonar.*/dashboard?id=XXX&pullRequest=181859
16:09:54.065 INFO Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
16:09:54.065 INFO More about the report processing at https://sonar.*/api/ce/task?id=---
We do not have sonar.qualitygate.wait=true. If we had, this would fail. EXPECTED. But we also expect PR decoration!
You can only see it actually failed when clicking on the link.
That is quite some effort for me. What do you think you will find in there? Before I do that, please confirm that this “PR decoration of Duplication” is really an implemented feature and should work. I personally think, that this is something that you just did not implement (yet).
Hey @KUGA2, pull request decoration when the quality gate fails because of a duplication threshold should work: I was able to reproduce it myself just now. It is not any different than any other quality gate condition. What I want to see in the debug-level server logs is if any HTTP request is failing but is being silently swallowed (therefore not producing a background task warning, which would otherwise be surfaced to the UI).
Scanner stdout has zero WARN messages.
Warnings related to PR decoration would not show up in the scanner logs because PR decoration happens in the server side in an asynchronous manner.
No warnings in project background tasks:
As I mentioned, warnings produced during PR decoration normally show up here, so this is an indicator that no warning related to PR decoration happened. However, I wouldn’t be 100% confident without checking logs.
PR decoration, in the sense of displaying the Quality Gate status in the PR, is working well.
Inline comments, however, are posted to Azure DevOps only for code issues, and not for duplicated code. It would be nice to also post some PR comments indicating which are the duplicated blocks of code. Otherwise, users might not immediately realize why the Quality Gate failed, instead, they need to switch platforms from Azure DevOps to SonarQube in order to see where the duplications are. This would be a UX improvement.
I see the point, and I’m going to flag this for the PMs to consider. Thanks!