Sonarcloud bot on github PRs not updating after a commit is submitted

Sonarcloud bot on github PRs not updating after a commit is submitted

Let’s walk through whats happening. First I create a PR, and my code has 2 code smells. I see these 2 code smells on my Github PR as well as SonarCloud itself. I then go fix those code smells by pushing a new commit to the open Github PR. Now the sonarcloud bot on github still shows the 2 code smells, plus sonarcloud site also still shows the 2 code smells. If you look at the background tasks and analysis, it did run another analysis and did find zero code smells, but sonarcloud page for that PR is not being updated. This is happening pretty consistent on a few Github repos we have, and not so often on others.

Hi,

Welcome to the community!

Just to make sure the dumb question gets asked: when you update the PR, your pipeline picks up the change and re-runs analysis, right?

Are you comfortable sharing org & project IDs, repo links publicly?

 
Thx,
Ann

Yes, SonarCloud picks up the change and re-runs the analysis, however the dashboard doesn’t display the new analysis. You have to go digging for it.

I am not comfortable sharing publicly

Hi,

:thinking:

Can you share some redacted screenshots of this? I’m having a hard time picturing it.

 
Thx,
Ann


Here is the screenshot of the analysis and the dashboard. The 2 code smells should have disappeared from the dashboard since the code doesn’t exists anymore.

Hi,

The first screenshot shows the background tasks? Is that the only place you see these analyses? And if so, wow are you verifying that these background tasks correspond to the PR in question?

 
Thx,
Ann

Based on time, yes those background tasks correspond to the PR in question

Hi,

What shows up in the two left columns? Were they successful? Were they for PRs?

 
Ann

PRs and successful

Hi,

Is there a way you can double-check the CI workspace to make sure it checked out the latest version of the code?

And if so, can you check the code around these two issues to see whether it does / does not match the latest code in the repo?

 
Thx,
Ann

Sonar states is ran on the latest code commit, but when you look in the code for that commit, it does not match. Another way of saying it, the changes in Github do not make it into SonarCloud even though SonarCloud states they are pulling the latest commit. Code doesn’t match

Hi,

Where do you see this “statement”? Could you provide a screenshot?

 
Thx,
Ann


The commit number on the right side of this image shows the commit that it analyzed. On github, this commit shows the code to be “const x = 5;”. If you go to the code tab on the image on the right the code will say “x=5”. The code on sonar does not match that latest commit.

Hi,

So it turns out that we just deployed an automatic analysis fix that’s probably relevant here. Unfortunately the ticket is in a private Jira project, but the title is

Checkout of pull requests sometimes get an outdated (or missing) commit

Can you make a small change to trigger a new analysis and see if this is fixed?

 
Thx,
Ann

I wasn’t able to retrigger the analysis on the same repo since we merged it already, but I did run a test for a new Pull Request and the things were working as expected. Thank you

1 Like