Sonarqube showing 0% code coverage for python

Using-

  • SonarQube- Developer Edition Version 9.3
  • Tox with travis CI
  • python coverage.py to generate coverage.xml
    I have been assigned to integrate Sonarqube into one of my company’s python repo and I know there are similar thread to this but none of them resolved my problem so here I am pasting all the things that I have done so far. we have been using travis CI with tox for test coverage for long, so using its coverage.xml for sonar-scanner’s -Dsonar.python.coverage.reportPaths I will be attaching the screenshot of logs where its show that scanner is reading and uploading this file. I am using command line to define its property

Hi,

Welcome to the community!

There’s a big gap in what you’ve provided from your analysis report. What happens after analysis finds the coverage report? Anything about it’s processing? Any errors?

Can you add -Dsonar.log.level=DEBUG to the analysis command line and copy/paste the full text of the analysis log?

 
Ann

Utkarsh,

I got the same assignment and having a similar issue.

Which tool are you using?
I’m using Gradle SonarQube plugin and i don’t see any specific report processing-related output in the console after running the sonar Gradle task.

But I’m effectively having the save issue at the end of the day: SonarCloud server shows no code and no coverage for my project.

One difference (probably) is that my company is primarily a Java shop and the project created in Sonar was probably using some ‘default’ (Java-related maybe?) configuration.

G Ann

Can you please let me know for Sonar projects (on the server side) some configuration might need to be chaged in a case like mine?

I’m trying to stick to ‘classic’ (Maven/Gradle) source code folder structure (like src/main/python, src/test/python). Maybe the Sonar project config needs to be adjusted to use the python subfolder for the coverage?
I’m not an admin and can’t check the project settings and don’t even see anything related to source paths and such in the UI (or maybe I just can’t find them?).
I know the coverage XML file is generated and sonar Gradle plugin doesn’t report any errors when I run it (so, hopefully, during the build the report gets discovered and uploaded to the server).

But still Sonar server doesn’t show any source files nor code coverage after I successfully run Gradle build.

Any suggestions before I turn to my Sonar admin?

Thanks, Ann for replying but it get resolved by doing a hit and trial

Hey,
I am using Travis CI with tox for sonarqube integration and generating a coverage report which get passed to the sonarqube.
if you are also able to generate and pass the report to sonarqube successfully then remember this coverage metric only gets shown when any new code gets added to the PR