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):
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?
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.