Hi, I’m setting up SonarCloud for a Python project.
I have disabled Automated Analysis and configured New Code to be based on the “Previous version”
Since I’m testing the setup, I’m running SonarScannerCLI on the same branch and passing it different branch names to see how that affects results in the SonarCloud.
I ran this command to load code quality and coverage for Main Branch:
$ sonar-scanner -Dsonar.projectVersion=2.135.7 -X -Dsonar.branch.name=develop
...
15:23:57.398 INFO: Branch name: develop, type: long-lived
...
15:24:20.464 INFO: 403/403 source files have been analyzed
15:24:20.464 INFO: The Python analyzer was able to leverage cached data from previous analyses for 0 out of 403 files. These files were not parsed.
15:24:20.464 INFO: Sensor Python Sensor [python] (done) | time=16938ms
15:24:20.465 INFO: Sensor Cobertura Sensor for Python coverage [python]
15:24:20.466 DEBUG: Using pattern 'dist/coverage/python/coverage.xml' to find reports
15:24:22.566 INFO: Python test coverage
15:24:22.568 INFO: Parsing report '<anon>/dist/coverage/python/coverage.xml'
...
15:24:22.735 INFO: Sensor Cobertura Sensor for Python coverage [python] (done) | time=2270ms
15:24:22.735 INFO: Sensor PythonXUnitSensor [python]
...
The scan seems to go ok, coverage is detected and uploaded. Below is the screenshot of what I see in SonarCloud.
I then make some dummy changes to the code (copy-paste some functions and rename them to fake uncovered sources), regenerate coverage metrics and rerun SonarScannerCLI making it appear as if it is running from feature branch:
$ sonar-scanner -Dsonar.projectVersion=2.135.7 -X -Dsonar.branch.name=feature/example
...
15:09:56.040 INFO: Branch name: feature/example, type: short-lived
...
15:10:19.894 INFO: 403/403 source files have been analyzed
15:10:19.894 INFO: The Python analyzer was able to leverage cached data from previous analyses for 0 out of 403 files. These files were not parsed.
15:10:19.894 INFO: Sensor Python Sensor [python] (done) | time=17313ms
15:10:19.895 INFO: Sensor Cobertura Sensor for Python coverage [python]
15:10:19.896 DEBUG: Using pattern 'dist/coverage/python/coverage.xml' to find reports
15:10:22.074 INFO: Python test coverage
15:10:22.076 INFO: Parsing report '<anon>/dist/coverage/python/coverage.xml'
...
15:10:22.271 DEBUG: Saving coverage measures for file <anon>'
15:10:22.271 INFO: Sensor Cobertura Sensor for Python coverage [python] (done) | time=2376ms
...
I then navigate to SonarCloud to browse coverage data for my feature branch and get the following:
My questions are:
- Why coverage appears to have no data (horizontal line directly under “Coverage” label)?
- Based on the fact that feature branch says “67.3%” instead of “67.4%” on the main branch, I understand that coverage data has been processed. How can I drill down into it on a file basis?
Any help would be much appreciated.