I am trying to analyze PRs on github manually using the scanner including the code coverage and duplications to check issues before merging to master.
I have another analysis on master using the same analysis parameters used for PR but with different parameters passed to the scanner.
I am using the latest docker image for sonarsource/sonar-scanner-cli following the documentation here
I am passing the coverage report in the sonar-project.properties and if I enable debug, sonar shows it is parsing it.
The problem is that only for PRs it does not show current branch coverage.
The more information you provide, the better. Screenshots… what you expect to see (what coverage do you expect to be reported?), how it is different from what you actually see reported, etc.
I am running an analysis on Drone CI whenever a PR is raised.
Running the following command in drone sonar-scanner -Dsonar.login=$SONAR_LOGIN -Dsonar.host.url=$SONAR_HOST -Dsonar.pullrequest.key=${DRONE_PULL_REQUEST} -Dsonar.pullrequest.branch=${DRONE_SOURCE_BRANCH} -Dsonar.pullrequest.base=${DRONE_TARGET_BRANCH} -Dsonar.pullrequest.provider=github -X gives me this result:
There seems to be an issue on how Drone checkouts the branch/PR, because I cannot find any other issues, the log of sonar-scanner on drone does not give me any warning.
Hi, guys. I think I found the root cause of the issue.
It is indeed how Drone cloning the pull request.Since Drone checkout from the source branch and merge the target branch into it. So if SonarQube argument is set to use target as base and source as branch, then SonarQube can not find any difference between these two branches.
Just like how the origin author does: -Dsonar.pullrequest.branch=${DRONE_SOURCE_BRANCH} -Dsonar.pullrequest.base=${DRONE_TARGET_BRANCH}
@Colin This leaves me to wonder what is the correct flow to do a PR analysis on CI manually? Should I do the analysis on the source branch without merging? Or do the analysis on a new branch like creating another branch from the target and merge the source branch and do the analysis?
I will be grateful for any help you can provide, thank you.