Hi all,
I’m running into an issue with PR analysis in SonarQube Developer Edition and hoping someone has seen this before.
We have SonarQube working as expected on several repos (though all of the uses master as main branch)
The problem:
When I create a PR from a feature branch into dev with a single added line, SonarQube reports ~22,000 “New Lines” instead of the actual change (one line of code). The project has ~10,000 lines on the dev branch that is included in the analysis. SonarQube correctly identifies the PR as “for merge into dev from feature/pr-sonarqube-test”, so the target branch resolution seems correct — but the new code calculation is clearly wrong.
This causes many unrelated issues to be reported against code I haven’t touched.
Setup:
- Azure DevOps Server (on-premise)
- SonarQube Developer Edition (on-premise, Kubernetes)
- The
devbranch is both the default branch in Azure DevOps and the Main Branch in SonarQube for the project - The
devbranch has been analyzed by SonarQube - A branch policy on
devtriggers a SonarQube quality gate on PRs
What I have already verified:
- The
devbranch new code period is set to “Previous version” in Project Settings → New Code - A standalone scan of
devruns on every merge, so the reference snapshot is current - The project key (
sonar.projectKey) is identical between the branch pipeline and the PR pipeline - The
devbranch is listed under Project → Branches and Pull Requests with a recent analysis and the correct line count - The PR is listed separately and shows the correct base branch
Any pointers would be greatly appreciated. Happy to share pipeline config or scanner logs if that helps.
Thanks!