SonarQube Scanner for Maven isn't scanning Python code (sonar-maven-plugin)

I’m using SonarQube Scanner for Maven (sonar-maven-plugin) with version 3.9.1. When I run:

mvn sonar:sonar -Dsonar.login=<sonar-token>

against my project, it will run successfully. However, my Python code didn’t get scanned properly. From the logs, I can see that it invoked many sensors (Sensor HTML, Sensor C# Properties, Sensor VB.NET Properties, etc), but none of them are about Python.

I want to know the way to configure it to pickup my Python code. Thanks.

Welcome :slight_smile:

you have not written where in the directory structure your Python code is located, but i’m almost
sure it’s not part of the maven standard directory layout.
You will need to customize sonar.sources in the pom, see this posting with a similar problem
for further details


1 Like

Hi Gilbert,

Thank you for your reply. Like you said, I didn’t put my Python code in standard Maven directory structure. Instead, I put my Python code inside a directory called “src”.

I tried to specify sonar.sources like you suggested. However, it didn’t work as expected, even I use a really broad config like **/src.

I suspect that the reason it didn’t work is not related to sonar.sources, but the “sensors” to scan the source code. For example, I see the logs contains the following lines:

INFO Sensor JaCoCo XML Report Importer ***jacoco*** (done) | time=1ms
INFO Sensor C# Properties ***csharp***
INFO Sensor C# Properties ***csharp*** (done) | time=1ms
INFO Sensor JavaXmlSensor ***java***
INFO Sensor JavaXmlSensor ***java*** (done) | time=0ms
INFO Sensor VB.NET Properties ***vbnet***
INFO Sensor VB.NET Properties ***vbnet*** (done) | time=0ms

Even though there are no C# or VB.NET code in my entire code base, it still runs the C# and VB.NET sensors. Therefore, I wonder if it’s because that the sensors for Python code are not there in the first place.

What do you think?


using Sonarqube 9.7.0 Enterprise, first test = sonar-maven-plugin: and
second test = sonar-maven-plugin:jar: just to be sure, Maven 3.8.6

Test with a Maven build, this src directory layout

    |   \---java
    |       \---com
    |           \---foo
    |               \---bar

this sonar.sources property in pom.xml


and it worked as expected, also scanning the python files.

Maybe you’re using another fileextension as configured in Sonarqube server !?
see https://yoursonarhost/admin/settings?category=Python
property sonar.python.file.suffixes