Code Coverage on PR does not display for new Code. Instead it always shows on entire code base

Template for a good new topic, formatted with Markdown:

  • ALM used (Bitbucket Cloud, Azure DevOps)
  • CI system used (Azure DevOps)
  • Scanner command used when applicable (Uses Azure DevOps Sonar Cloud plugins)
  • Languages of the repository (C#, .Net Core, React / Angular, Python)
  • Error observed (Code Coverage on PRs does not populate correctly. Instead it displays the Code Coverage on entire codebase.)
  • Steps to reproduce (For Every PR when the CI runs, it shows this error prone data for Code Coverage + Code Smells on entire codebase rather showing it only for new code)
  • Potential workaround (Not able to find out yet)

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hey there.

Has your main branch (the branch the PR is targeting) been analyzed yet?

Yes Colin.
It have been analyzed before multiple times, but every time, it is not giving desired results.
Please do let me know in case if you need further more information my end.

It might be helpful for you to provide a screenshot indicating the unexpected/undesired results.

Here is screenshot, Colin for one of the analysis after the PR is created.

This PR has very few changes into it but still it is showing 16K lines analysis.


It says the last analysis had a warning (in the upper right). What is the warning?

Without SCM information, SonarCloud won’t be able to accurately detect New Code – so it has detected everything as New.

Is this project using Git?

Yes that is right Colin.
This project uses Git and we have our code in Bitbucket and used Azure DevOps for CI/CD

Thanks. Is there a .git folder in the directory where anaysis starts from?

Yes the .git folder is present at repository folder level.

And that folder is present when pulled from Bitbucket to the Azure DevOps pipeline? You might try executing a ls .git or similar while in the Azure DevOps pipeline.