SonarQube Version : 8.6.0.39681 [Developer edition]
Issue: Irrelevant comments on the pull requests
Information:
- We have integrated SonarQube with Azure DevOpsServer(ADO)
- In ADO gated commit branch policy is enabled
- Quality gate status is also enabled for the PRs
- In SonarQube we have enabled PR decoration to get the feedback directly on pull requests.
- For every PR & Master branch we are triggering SonarQube scan
In some cases we are getting irrelevant comments on the PRs, which means we are getting comments for the files which are not even part of the PR. Please refer below images
ADO:
SonarQube:
We are using azure yml pipelines & for checkout we are using following git commands
FOR PR Branches
Set-Location “local path”
git init
git remote add origin “repository URL”
git -c http.extraheader=“AUTHORIZATION: bearer $($env:AccessToken)” fetch --force --prune --progress --no-recurse-submodules origin +refs/heads/:refs/remotes/origin/ +refs/pull/$(System.PullRequest.PullRequestId)/merge:refs/remotes/pull/$(System.PullRequest.PullRequestId)/merge
git c http.extraheader=“AUTHORIZATION: bearer $($env:AccessToken)” lfs fetch origin refs/remotes/pull/$(System.PullRequest.PullRequestId)/merge
git checkout --progress --force refs/remotes/pull/$(System.PullRequest.PullRequestId)/merge
For Master and feature
git clone --single-branch --branch “branchName” --depth 1 -c http.extraheader=“AUTHORIZATION: bearer $($env:AccessToken)” “repository URL” “local path”
New Code Definition in SonarQube is set as Previous Version