Suppress individual rule violations in SonarLint for VS Code

Hello,
I’m using VS Code 1.49.1 with SonarLint 1.17.0 (community) on Linux Mint 19 Tara. Python rule python:S1854 (unused assignment) is firing incorrectly. How can I suppress the individual instance without disabling the rule? [Visual Studio has Solution Explorer->References->Analyzers which is not present in VS code.] Also, where can I find the list of SonarLint settings that I can modify in settings.json in addition to those available in the Settings pane within VS code?

Hello, thank you for your question.

The current situation is that manual suppression of Python rule violations is only supported in connected mode with SonarQube or SonarCloud: any issue marked as “false positive” or “won’t fix” on the server won’t be shown in the IDE.

Manual suppression in SonarLint without connected mode is a long debated feature, I believe it deserves a dedicated thread in the suggest new feature category.

In SonarLint for VSCode, the full list of rules that can be toggled and configured in settings.json is available in the “SonarLint Rules” view in the explorer; this will help you browse existing rules, toggle their activation and check whether they support parameters.

Screenshot from 2020-10-15 10-38-22

Finally, if you have a minimal reproducer for a false positive on python:S1854, could you please post it here so that we can investigate why this is happening and improve the product for everyone :slight_smile: ?

Thanks!

Thanks for the quick reply! The false positive was not false though it was difficult to spot. The rule (Unused Assignment) says “A dead store happens when a local variable is assigned a value that is not read by any subsequent instruction.” The local variable (underlined with a red squiggle) was clearly being read about 20 lines later. It was not immediately obvious to me that variable was mistakenly used in a for loop between the original assignment and the read. The fact that it was in for loop made it more difficult for me to spot. I apologize.

1 Like

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