Can we configure the custom rules in Sonarlint?

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

And a thorough description of the problem / question:
I wanted to set the rules like S107, Cognitive Complexity in SonarLint. Can I do that? I don’t want to use the connected mode to SonarQube as I don’t have the the UserName/Password/Token of that. I am new with the Sonar environment.

Hi @Rahul_K - welcome to the community!

Yes, you can configure the Sonar C# and Visual Basic rules as follows:

  1. Create a file called SonarLint.xml in the appropriate format (example here)

  2. Add a reference to that file to your MSBuild project as follows:

  <AdditionalFiles Include="[... absolute or relative path...]\SonarLint.xml" />

For a C# project, Visual Studio will show the file properties as follows: