Duplicate code smells when importing PyLint report

Hi Community,

We are running the python analysis, importing a PyLint report in addition to the SonarQube analysis.

The imported PyLint issues are being created with each run, SonarQube does not seem to be track already existing issues and re-creates them with each run.
See an example for the Pylint rule Unused variable in the attached image.
sonarqube_duplicate_error|690x324

In addition to these duplicate warnings, resolving the code smell does not remove the existing, duplicated warnings.

Using SonarCube version 7.9.1 and SonarQube Scanner 4.2.0.1873
PyLint report was generated with pylint-2.7.4 and python 3.7, running pylint --output-format=parseable.

Any help in resolving this would be greatly appreciated.

~Julian

Hi,

When you click ‘See Rule’ do you see the same rule identifier attached to each image? I ask because that’s part of how SonarQube identifies which issues are new

 
Ann

Not completely sure on what the rule identifier is, however all these are marked with Pylint:W0612 in the top right

image

This was used as example, we are getting the same behavior with all the additional Pylint rules

Hi,

Would you be able to check if you can reproduce the problem with SonarQube 8.8?

 
Thx,
Ann

Hi Ann,
I’m working with Julian, unfortunately we don’t have SonarQube 8.8 as we are using LTS version and we don’t have test environment for SonarQube (We have a Developer edition).

My request to have a 14 days trail license to test new version was refused. I did this request in the past to test the new version before to deploy it in production (as we need it to test PL/SQL part of our projects) but it was refused because trail licenses are only for new customers (Sonar contact’s answer).

I read that the 8.x LTS version should be avail Q2 2021, so before we can’t test. Except if now there is way to build test environment.

Thanks
Sebastien.

Hey @SebG

A Community Edition of SonarQube v8.8 should give you a good environment to test in. :slight_smile: Python analysis has changed significantly in the v8.x series, particularly with regard to importing Pylint issues.

All that said – I would check your Pylint report to see if thee issues are being reported multiple times (in which case, SonarQube is just doing the right thing with the information it’s given and reporting issues)

2 Likes

Unfortunately the PyLint report is not reporting these issues multiple times.

Will disable the additional PyLint rules until 8.x LTS is available

Hi @Colin
Yes correct but I don’t want to build a test environment to cover only 5% of our code. Our main usage of SonarQube is to scan PL/SQL. If I’m not wrong Community Edition does not scan PL/SQL.

Thanks

Hi All,

We have now upgraded to SonarQube 8.9.
However upon importing a PyLint report duplicate Issues are still being created.

In attached screenshot, building the same code three times produced the issue pylint:R1705 three times, all on L97.
The same is happening with all other PyLint issues.
SonarQube issues are functioning as expected.

Any help is greatly appreciated

Oddly enough, the duplicate issues keep the creation date of the initial issue.
In the screenshot, the runs where executed within 20 minutes of each other, however all three issues show 39 minutes ago

Hi,

Could you provide a reproducer?

 
Ann

Will setup something to reproduce over the weekend.

Kind regards,
Julian

2 Likes

While reproducing, I discovered the source of the problem.
Due to a problem in our Jenkins setup, the workspace was not being cleaned between runs.

This caused the pylint report to append to the previously present report, duplicating the issues in the report which were then imported into SonarQube.
We used tee to write the report and output to stdout alongside the -a flag.
This caused the append but was only outputting the newly appended report to stdout.

In the end, this was all due to a miss-configuration on our side.

Kind regards,
Julian

1 Like

Thanks for the followup Julian! I’m quite sure this will be useful in the future.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.