- ALM used - GitHub
- CI system used - Azure DevOps
- Scanner command used when applicable - See our Azure DevOps pipeline excerpt below
- Languages of the repository - Go
- Error observed - Comments marked as uncovered code inconsistently on PRs
- Steps to reproduce: We open PRs that add functions with comments and comments, closing brackets, and other non-code lines are marked as uncovered code when they should not be. We use multiple coverage files and think there may be inconsistent merging of the coverage files. We have already tried upgrading the go toolchain, using different coverage modes, and more at the source.
- Potential workarounds - Substantially reducing quality gate percentages, force merging PRs
We use Azure DevOps to run SonarCloud analysis. Here are the relevant pipeline steps with configuration:
- task: SonarCloudPrepare@3
inputs:
SonarCloud: "SonarCloud"
organization: "ui"
scannerMode: "CLI"
configMode: "file"
extraProperties: |
sonar.go.coverage.reportPaths=**/coverage-*.out
sonar.go.tests.reportPaths=**/report-*.xml
sonar.exclusions=**/*_test.go,**/report.xml,**/report.json,**/dist/*,**/zz_generated*.go,pkg/clientset/**,**/hack/**,pkg/mapper/**,cmd/mazewalk/mapper/**,**/*.pb.go
sonar.test.inclusions=**/*_test.go,test/**
sonar.sources=.
sonar.tests=.
sonar.projectKey=UiPath_mazewalk
sonar.projectName=mazewalk
sonar.projectBaseDir=$(Build.Repository.LocalPath)
- task: SonarCloudAnalyze@3
- task: SonarCloudPublish@3
inputs:
pollingTimeoutSec: "300"
On PRs, we see comments marked as uncovered code when they should not be like so:
On the main branch, the comments are correctly not counted as code. This is the output we expect on branches:
We have also seen function signatures, closing brackets, and other comments marked as code when they should not be.
Here are our coverage files. We have a 4th but it’s over the size limit for this forum. I renamed them to txt so I could upload them, but they always have a .out suffix otherwise. I included the branch coverage files for our branch (not producing the expected sonarcloud output) and the main branch coverage files (producing the expected sonarcloud output)
MAIN - coverage-integration.out.txt (2.1 MB)
MAIN - coverage-e2e.out.txt (1.7 MB)
MAIN - coverage-cluster.out.txt (1.3 MB)
BRANCH - coverage-integration.out.txt (2.1 MB)
BRANCH - coverage-e2e.out.txt (1.7 MB)
BRANCH - coverage-cluster.out.txt (1.4 MB)
If you need any more information please let me know. Thank you in advance for the help!

