I’m using SonarQube Version 6.7.2, SonarPython 1.10, SonarQube Scanner 2.8, PyLint 1.9.2, Python 2.7
When the scanner starts I get the following output ind the log:
INFO: Sensor PylintSensor [python]
INFO: Sensor PylintSensor [python] (done) | time=1ms
INFO: Sensor PylintImportSensor [python]
WARN: Pylint rule ‘C0326’ is unknown in Sonar
WARN: Pylint rule ‘C0330’ is unknown in Sonar
[…]
and this repeates about 1000 times.
How can I get rid of it? And how can I see the results of pylint in sonarqube?
You have to activate the Pylint rules in the quality profile of your project.
That’s a limitation of the current “import” mode for Pylint: we will probably change that in the future now that SonarQube 7.2 makes it easy to import issues from external analyzers.
as I don’t know when I will do the upgrade to 7.2, I have to cope with what I have
It’s quite difficult to find the matching rules. In the log, I see only codes like C0200 and E0611, but how can I find the matching rule in SonarQube? Shall I click through all the inactive rules to find the small number in the upper right corner?
What do I do with rules that my pylint version simply doesn’t know? For example, C0113 (unneeded-not, C0113, Consider changing “%s” to “%s”)
Did you try to activate all the rules from the “Pylint” repository in your quality profile?
That should be the easiest solution and it should work even if your pylint version doesn’t have all rules.
when I first setup my code check environment, I installed PyLint and did quite some work with configuring the rc-file, so that it makes sense for me and my development. As far as I can see, PyLint has around 150-200 rules, SonarQube has 50+
I don’t want all 250 rules activated, but only the ones, I either configured via pylint.rc-file and/or sq-rules configured in the UI.
Another approach does not really make sense to me, because why should I configure anything in the rc-file?
Based on your logs, it seems that you’re using Pylint “import” mode: SonarQube reads the Pylint report you provide with the sonar.python.pylint.reportPath property and it filters out the issues on rules which are not part of the quality profile.
If you want to see all the issues which are in your Pylint report, then your SonarQube quality profile has to be a superset of the rules you configured in Pylint.
The easiest way is to activate all Pylint rules on your SonarQube quality profile: the rules which are not activated in Pylint configuration will produce no issue in your pylint report, and therefore no issue in SonarQube.
I have an issue with this but I’m not using the PylintImportSensor.
I’ve just enabled 36 pylint rules, and I don’t have a pylint.rc file specified or configured.
My log is full of warnings for rules which are “unknown in Sonar”. I assume these are failing against some of the ~289 pylint rules which I have not configured in SonarQube.
I feel that the scanner shouldn’t generate a warning for a rule which is not enabled. On a large python project, this created 53,830 lines of unnecessary noise, increasing the size of the build log significantly.
|[13:00:14]|[Step 2/2] INFO: Sensor Python Squid Sensor [python] (done) | time=2715ms|
|[13:00:14]|[Step 2/2] INFO: Sensor PylintSensor [python]|
|[13:00:16]|[Step 2/2] WARN: Pylint rule 'C0103' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0303' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0301' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0304' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0103' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0111' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'R1705' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0111' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0111' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0103' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0111' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'W0622' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0103' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0103' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0103' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0103' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0103' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0103' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0103' is unknown in Sonar|
|[13:00:19]|[Step 2/2] WARN: Pylint rule 'C0103' is unknown in Sonar|
SonarQube details are:
INFO: SonarQube Scanner 3.2.0.1227
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
INFO: Windows 10 10.0 amd64
INFO: SonarQube server 7.2.1