SonarLint in VS2022 ignores settings file

Please provide

  • Operating system: Windows 10
  • SonarLint plugin version:
  • Programming language you’re coding in: C#
  • Is connected mode used: n.a.

And a thorough description of the problem / question:

I’ve installed sonarlint extension as a nice static analysis option. However i do not agree with certain rules causing warning and would like to change them.
This is to the extend that i’m willing to uninstall it again if i cannot get this to function. Specifically S3358.

in C# when using e.g. AutoMapper, language features are not available to avoid using in this example ternary expression without tediously making long winded implementation, and we use it a lot.

At the same time we take warnings seriously, so I cannot have lots of these warnings because of lack of context however much I might agree in principle we have use cases when it is impractical because alternative coding is not available and when adding a to Settings.json, my sonarlint.rules a

“csharp:S3358”:{ “level”: “off” }

nothing at all happens, please advice further actions somebody, before i have to scrap the effort and not promote it to my organization because it is not customizable.

I come from re-sharper where all is configurable but now a bit on the wild side to see what’s in the community to top off what VS 2022 can already do as it is improving as a platform.

Anybody had any luck controlling the sonarlint.rules locally and preferably so that it affects all. it attempts to install on some roaming profile which should also preferably be placed within repository so that everybody will not have to fix the same issues

Hi @TVNielsen - welcome the community.

The SonarC# and VB.NET rules are Roslyn analysers that are executed directly by Visual Studio, so the settings in the settings.jons file are not used. You can enable/disable the rules in standalone mode using the normal Visual Studio mechanisms i.e. rulesets and .editorconfig files.

If you are using Connected Mode, the rules will configured for you.