Pull Request analysis incorrectly reporting thousands of changed files

Hi All

We are using SonarCloud with AzureDevOps and have a pipeline that runs SonarCloud for PRs. For reasons that I can’t fathom, some (but not all) PR analyses erroneously report thousands of changed files and cause developers to have to address hundreds of unrelated issues in the AzureDevOps PR. For example, this PR has just one changed file (screenshot from Azure DevOps):


whilst the SonarCloud analysis thinks 7.2k files have been changed:

Can anyone help me understand what’s going on and how to fix this please?

Many thanks - Graham

Hi,

Typically when you see issues on old code reported in a pull request, it’s because there was a problem reading the SCM data, which is how analysis determines what’s new. Either that, or the branch being targeted by the PR wasn’t available in the local repository.

If you check the bottom of your analysis log, do you see a message about SCM detection being disabled?

 
Ann

Hi

Thanks for that - I don’t see any SCM being disabled message. I do see:

INFO: SCM writing changed lines
INFO: SCM writing changed lines (done) | time=27ms

so I guess it’s working. There is a warning about Shallow clone detected, so I’ll look at fixing that, but is it related?

Thanks - Graham

Hi,

Yes, that’s absolutely related. Fix that and it should fix your problem.

 
Ann

Quick update: I’ve addressed the Shallow clone detected issue (for anyone using Azure DevOps YAML Pipelines as part of the checkout you need fetchDepth: 0) and the first PR looks to be working. That’s not definitive though as the problem wasn’t consistent. It will take a few weeks to gather sufficient evidence either way but I will post back in due course.

1 Like