SonarAnalyzer rules not matching SonarQube

We are working with Sonar community version 8.6 and SonarAnalyzer.CSharp version 8.17. The active Quality Profile is the Sonar way by default.
We have a ruleset file that contains the following references:

<Rules AnalyzerId="SonarAnalyzer.CSharp" RuleNamespace="SonarAnalyzer.CSharp">
  <Rule Id="S101" Action="None" />
  <Rule Id="S1135" Action="None" />
  <Rule Id="S3458" Action="None" />

When we open the Rulesets with VS, many other disabled rules appear, such as S107 that appears active in SonarQube but inactive in VS.

Is this the expected behavior? Active rules shouldn’t match? How can we set them to match?

1 Like

Hello @eugeniolt,

It was unclear from your message - are you using SonarLint? or are you referencing SonarAnalyzer.CSharp as a nuget package?

If you’re using SonarLint, do you use connected mode? It will create a ruleset file that matches your server configuration and your projects will automatically reference it, so you wouldn’t need to make any changes to it.

If you’re using the analyzer as a nuget package, you can download the ruleset file from your SQ server: navigate to the quality profile’s page and look for “SonarLint for Visual Studio Rule Set” exporter at the bottom left.

We are using the analyzer as a nuget packge, we download the ruleset file from SonarQube and now it works correctly.


1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.