# Can we configure the custom rules in Sonarlint?

**URL:** <https://community.sonarsource.com/t/can-we-configure-the-custom-rules-in-sonarlint/76427>\
**Category:** Visual Studio\
**Tags:** sonarqube, dotnet, sonarqube-ide\
**Created:** [November 22, 2022, 7:06am UTC](https://community.sonarsource.com/t/can-we-configure-the-custom-rules-in-sonarlint/76427 "2022-11-22T07:06:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_K](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rahul_k/32/39368_2.png) [@Rahul\_K](https://community.sonarsource.com/u/Rahul_K)\
**Post date:** [November 22, 2022, 7:06am UTC](https://community.sonarsource.com/t/can-we-configure-the-custom-rules-in-sonarlint/76427/1 "2022-11-22T07:06:04Z")

</div>

- Operating system: Windows 10 E
- SonarLint plugin version: 6.9.0.54300
- 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.

---

<div class="post-metadata">

**Author:** ![duncanp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/duncanp/32/293_2.png) [@duncanp](https://community.sonarsource.com/u/duncanp)\
**Post date:** [November 24, 2022, 3:21pm UTC](https://community.sonarsource.com/t/can-we-configure-the-custom-rules-in-sonarlint/76427/4 "2022-11-24T15:21:55Z")

</div>

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](https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/.sonarlint/sonaranalyzer-dotnet/CSharp/SonarLint.xml))

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

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

```

For a C# project, Visual Studio will show the file properties as follows:  
 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/b/4/b41fa97f3eb4090a9975f97f83822578a0b0f724.png)

---

<div class="post-metadata">

**Author:** ![MrAntix](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mrantix/32/57593_2.png) [@MrAntix](https://community.sonarsource.com/u/MrAntix)\
**Post date:** [May 11, 2024, 9:34am UTC](https://community.sonarsource.com/t/can-we-configure-the-custom-rules-in-sonarlint/76427/6 "2024-05-11T09:34:19Z")

</div>

the reference to an example gives a 404

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [May 14, 2024, 5:07am UTC](https://community.sonarsource.com/t/can-we-configure-the-custom-rules-in-sonarlint/76427/7 "2024-05-14T05:07:46Z")

</div>

@MrAntix Here’s a copy from a previous version of the repo: [sonar-dotnet/analyzers/.sonarlint/sonaranalyzer-dotnet/CSharp/SonarLint.xml at 8.56.0.67649 · SonarSource/sonar-dotnet · GitHub](https://github.com/SonarSource/sonar-dotnet/blob/8.56.0.67649/analyzers/.sonarlint/sonaranalyzer-dotnet/CSharp/SonarLint.xml)
