Set Python version with sonarqube args

Hi,

We are using Sonarqube 7.6.0.21501 version and Code Analyzer for Python 1.11 (build 2473) installed that version does not support Python 3.6. We have a plan to upgrade the SonarQube version as well as the Python plugin version.

Some of our projects are written in Python version 3.6.8 and some of them 2.x so when we run the sonarqube code analysis we see some false-positive errors such as **"return" and "yield" should not be used in the same** **function**. This is actually not an error for Python version 3.6 so If somehow I can set it python code with SonarQube Args like sonar.language=py for version sonar.language_version=2.6 then it can be a workaround until the upgrade.

  • which versions are you using 7.6.0.21501
  • what are you trying to achieve Python code analysis

Can you please confirm with version 7.7 We cannot use preview mode anymore?

Release 7.7

  • The preview/issues mode of scanner has been removed

What could be the latest supported python plugin version for `7.6.0.21501?

Thanks,
Tolgay Gul

Hi @kenotsolutions,

Thanks for posting and welcome to the community! :smiley:

There is currently no mechanism for specifying the version of Python that you’re analyzing. But we’ve recognized that this is a problem and there’s a ticket in our backlog to address this. At this stage I don’t have a timeframe for when this will be delivered but you’re welcome to watch the ticket for updates.

Yes, I confirm that preview mode was dropped in SonarQube 7.7. You should take a look at branch and pull request analysis as alternatives.

Regards,

Cameron.

Hi @kenotsolutions,

Just to complete @Cameron’s answer. Our current strategy is to disable by default rules which could raise False Positives on either python 2 or python 3. We will probably add later a “python version” parameter but this has to be done carefully so that we don’t impact our user experience.

If you want to enable rules specific to python 2, such as “return” and “yield” should not be used in the same function (S2712), you can create a separate quality profile for your python 2 projects and enable these rules just for them.

Regards,

Nicolas.

Any new update adding a new parameter for the language version? PHP 5, python 3.6x etc

thanks