Fixing all issues on a GitHub PR does not trigger removal of outdated Sonar comments

sonarcloud
github
pull-request

(Yoann Rodière) #1

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: https://github.com/yrodiere/hibernate-search/pull/37#pullrequestreview-155383797

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.


(Fabrice Bellingard) #3

Hi Yoann,

if I’m not mistaken (@janos will probably confirm), this used to work properly a couple of weeks ago: comments would be updated every time changes are pushed, and so you would end up with a “clean” PR when all the issues were fixed.

Problem: it seems that there was a recent change on GitHub side which broke our ability to keep that logic (something like review cannot be deleted anymore).

We plan to update the way we provide feedback on PR and use the new Check API: MMF-1305. I hope and believe that this will be the opportunity to remove this noise.


(Yoann Rodière) #5

Hi Fabrice,

Ok, thanks for your answer. It seems odd that the cleanup works correctly when there are still issues, but not when all issues are solved, but I guess things are implemented differently in that case.

Anyway, taking advantage of the Check API would be great! I’ll subscribe to that ticket.

Have a nice day.