Disable C# rule in SonarLint.xml

Hi there :wave:t2:

I’m using SonarLint for C# on Codacy. Now I’d like to disable some Sonar rules for C# (S121 and S3216) within SonarLint.xml, but I don’t find any documentation how I can do this. I already found this example, but unfortunately it does not contain any example of how to disable a certain rule.

Thanks!

  • Operating system: I don’t know Codacy’s OS
  • IDE name and flavor/env: On Codacy, using C#
  • SonarLint plugin version: I don’t know the version on Codacy
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): I don’t know

push

Please help, guys

Hi @mu88. Codacy is a third-party commercial service. I have no idea how they consume the Sonar C# analyzers. You should contact them for support.

FYI SonarLint.xml is used to pass parameters to rules, not to enable or disable them. When using SonarQube with Connected Mode, you would enable/disable the rules in the Quality Profile for the Sonar project.

1 Like

Hi @duncanp

Thank you for your reply :slight_smile: I had already contacted Codacy before I posted my question here because they told me that custom rule behavior can be controlled via SonarLint.xml - that’s the way how Codacy gets configured.

Are you saving that disabling or reducing a rule’s severity is not possible via SonarLint.xml? Is the only way to accomplish this via .editorconfig?

Hi @mu88,

Yes.

If you were using the SonarAnalyzer NuGet packages directly, or using SonarLint for Visual Studio in standalone mode, then you could set the severity through ruleset files or .editorconfig. I don’t know what is possible when using Codacy.