How to disable SonarLint for test projects

Niek Jannink picture Niek Jannink · Aug 17, 2015 · Viewed 8.6k times · Source

I installed SonarLint in VS 2015 and it looks like a great extension with lots of potential.

At the moment the extension is also analysing my test projects and giving warnings about this. How can I disable inspection of specific (test) projects?

Update Its not about disabling specific Sonar rules or projects in SonarQube, but its about the Visual Studio extension SonarLint.

Answer

jessehouwing picture jessehouwing · Aug 17, 2015

In Visual Studio, open the project and then dig into the Reference section. There choose to edit the active rule set:

Open Active Ruleset

In the screen that opens select/deselect the rules you want for the specific project. Then hit save. This will most likely create a new .ruleset file in your project and instruct Roslyn to use that instead of the standard set.

The result is that the project file is updated with the <CodeAnalysisRuleSet> tag like this:

<CodeAnalysisRuleSet>UnitTests.Core.ruleset</CodeAnalysisRuleSet>

You can also use the add new file wizard and pick the "Code Analysis Rule set" option:

enter image description here

Then from the Analyze menu select "Configure Code Analysis for Solution", your newly added rule set can be selected from there and assigned to the project you want:

enter image description here