I have installed sonar lint extension on my visual studio code editor and I was wondering if there is a way to enable or disable the rules which are used by the analyzer? There is a way to do it in Visual Studio and Eclipse but I couldn't find a way to enable or disable the rules on Visual Studio Code.
I do have SonarQube running on my local server where I can disable and enable the rules from the Admin UI page. If there is a way to configure the SonarLint with the server, that would be cool. But I am not sure how to do it. If anyone does, please point me in a right direction.
In SonarLint v3. 6 and above for VSCode, to set up SonarQube/SonarCloud connections, open a SONARLINT CONNECTED MODE view in VSCode. Select either Add SonarQube Connection or Add SonarCloud Connection, and complete the fields. For SonarQube connections, provide your SonarQube Server URL and User Token.
Open the “SonarLint Bindings” view in Eclipse, right click on your connection, and click “Update all projects bindings”. I know the root cause. It is because these rules are default not activated. I shoud copy the built-in profile and activate them, then Update All Project Bindings from SonarLint.
SonarLint maintains a long list of rules that are executed on source code to generate issues. You can select exactly which rules you want to include in analyses via the Rules Configuration dialog. To access it: Bring up the Preferences dialog via Window -> Preferences from the main menu.
Installing the SonarLint VS Code extension: Go to VS Code Side Bar › Extensions or Press Ctrl + Shift + X in Windows. Search SonarLint Extensions in Marketplace. Click on the extension SonarLint. Click on Install.
Goto settings and search for sonarlint
Click on Edit in settings.json
Add to "sonarlint.rules":
the rule you wand to disable as follow:
"javascript:S1488": {
"level": "off"
}
the rule code is displayed in the floating box
Currently there is no way to use the connected mode which allows the user to configure (enable/disable) the rules on the SonarLint.
According to the discussion on the SonarLint Google Group.
It's very likely that this feature will be added soon (within the year), as we already started developing it for other flavors of SonarLint (Eclipse).
This feature is currently in work in progress and can be tracked here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With