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.
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
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.
using Sonarqube 9.7.0 Enterprise, first test = sonar-maven-plugin:3.7.0.1746 and
second test = sonar-maven-plugin:jar:3.9.1.2184 just to be sure, Maven 3.8.6
Test with a Maven build, this src directory layout
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