Components: GitHub PR decoration
Versions used: Sonarcloud, so no idea. Latest, probably?
Errors observed
When fixing the very last issues in a PR and pushing to that PR, Sonar does not remove the comments about the fixed issues.
This is a bit inconsistent with the behavior when you push to a PR and only fixed some issues, in which case previous comments are removed. Maybe that’s related to the fact Sonar does not add reviews to PR that don’t have any issue (anymore)?
And it’s a bit confusing, too: when you look at the PR, it seems there are still issues, but the Sonar check status is green…
Steps to reproduce
- Open a PR on GitHub with analysis issues.
- Wait for the Sonar check: the Sonar check status will be set to “red” and a review will be added with comments on lines with issues.
- Push a new commit to the PR that fixes all the issues.
- Wait for the Sonar check: the Sonar check status will be set to “green”, but the existing review will be unchanged and no new review will be added to explain that the PR is now free of any issue.
Potential workaround
In most cases fixing the issues will require changes to the line on which Sonar commented, so GitHub will automatically hide the comments as outdated. Example: Test Sonar PR decoration by yrodiere · Pull Request #37 · yrodiere/hibernate-search · GitHub
However, I can imagine cases where changes are on a different line, which means GitHub will not hide the comments. And it seems at least some people on the Sonar team share my opinion.
Suggestions
If the idea is to keep the issues for “archive” purposes, maybe Sonar could just “Resolve” conversations on out-of-date reviews automatically instead of deleting comments? Then it would not be a problem to also do it when all issues are fixed.