Github Action PR edit comment instead of create comment

I’ve setup SonarCloud Github Action on my repository in GitHub. I works great; every time a PR is created it runs the analysis. It also runs for every commit within the PR, creating a new comment with new information and deleting the old comment.

Would it be possible to edit the first existing comment, instead of creating a new comment every time?

This would prevent spamming people’s inbox.

Codecov does this too.

Example PR: Test with different eslint & angular versions in CI by jerone · Pull Request #4 · jerone/eslint-plugin-angular-template-consistent-this · GitHub

2 Likes

Hi @jerone ,
Thanks for your contribution.
I think this implementation design was chosen for the following reason: we wanted to let users be able to track changes made on PRs.
If the comment is only updated, there is no way for your teammates to know what has been done on the PR (of course they can see commits title and content, but still).

Isn’t there any way on GitHub to prevent notifications?

Hope to help :slight_smile:
Christophe

My example PR was short, but if it contains a long discussion, the latest overview comment would be out of initial view very quickly. In contrast to the Codecov comment, which stays at the top for easy access.

Another reason to use edits (instead of deletes), is history. Right now, old comments are being deleted. Removing any history about improving quality. Again, see Codecov edited-dropdown.

Isn’t there any way on GitHub to prevent notifications?

Sadly not that I know of. You can block an bot, but that will ignore all messages.

It’s sad but I’m disabling SonarCloud comments on pull requests because of this, it’s really annoying for pull requests with multiple commits (or push force).

Other tools such as codecov edit their message which allows for history and doesn’t send a new notification each time.

image

1 Like

For projects where SonarCloud is a requirement to be met, current implementation might create awareness.
But for projects where SonarCloud is not required, current implementation could be considered annoying.
It might be best to have a configurable option between edit or create the overview comment.

Please like my first post to create awareness.

Hi

That is an interesting topic. From what I understand the root problem is related to not overwhelming developers with notifications every time a PR is updated and a new PR analysis has been done.
Regarding your request, we don’t have this feature available at the moment but we take into consideration your need. In this case, we don’t have any plans to address this on our current roadmap, but if we find evidence that it’s a wider problem we’ll look into it further.

Alexander

Hi everyone,

wanted to do a quick follow-up on this topic as I recently integrated the sonarcube action and I have to agree with the original post. Will this be configurable at some point? If not, can I somehow get the raw output from somewhere and disable the auto post?

Thanks
Benedikt

Hi all,

Chiming in that as a new user of Sonarcloud I am also facing this issue. I really don’t like how Sonar Quality Gate creates a new comment every time and I would much prefer it if it would edit instead.

Like SirLynix I have now disabled the comments altogether but that is not an ideal solution either.

I would really appreciate a config such as sonar.pullrequest.github.edit_summary_comment or alternatively let sonar.pullrequest.github.summary_comment take a value of true, false, or edit

Hey,

We recently integrated SonarCloud into our open-source project to improve our code quality through the automatic analysis. However, we’re facing the same issue where SonarCloud creates a new comment on each pull request instead of updating an existing one. This behavior is very frustrating for us, as it leads to a flood of notifications, especially in a highly active project like ours.

It would be a big improvement if SonarCloud could update an existing comment rather than creating new ones!