Rules set to none or suggestion in EditorConfig show up as warnings during dotnet build

I believe this might be a very similar topic to Sonar cloud - Ignoring rules with editorconfig is not working - SonarQube Cloud - Sonar Community, but I have uncovered way more Analyzers that don’t work. The guidelines state to create a new topic if the previous one is fairly old.

We are currently observing a similar issue in our Azure Pipelines runs. We use the following steps:

  • SonarQubePrepare
  • dotnet restore
  • dotnet build
  • SonarQubeAnalyze
  • SonarQubePublish

For most analyzers, the .editorconfig is correctly handled by SonarQube. If I run the build locally, I get no warnings at all. If I remove SonarQube from the pipeline, I get no warnings at all. With SonarQube, at least the following analyzers begin to show up as warnings:

  • S6603
  • S1121
  • S1135
  • S6605
  • S6602
  • S3267
  • S107
  • S3776
  • S5332
  • S1075
  • S6444
dotnet_diagnostic.S1121.severity = suggestion

There are probably even more. During further testing I realized that changing the severity from “suggestion” to “none” actually removes it completely in my case. However that only worked for S1121. For other analyzers like S6605 this did have no impact.

There are no other editorconfig files which define rules for these analyzers. And since changing the severity of S1121 has an impact, I’m sure the file is correctly recognized.

We’re using .NET8 and SonarQubePrepare logs this:

SonarScanner for MSBuild 9.0.2
Using the .NET Core version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
15:32:58.603  Updating build integration targets...
15:32:59.475  Using SonarQube v10.4.1.88267.
15:32:59.548  Fetching analysis configuration settings...
15:33:00.109  Provisioning analyzer assemblies for cs...
15:33:00.11  Installing required Roslyn analyzers...
15:33:00.11  Processing plugin: csharp version 9.19.0.84025
15:33:00.259  Processing plugin: vbnet version 9.19.0.84025
15:33:00.299  Processing plugin: securitycsharpfrontend version 10.4.0.30099
15:33:00.552  Provisioning analyzer assemblies for vbnet...
15:33:00.552  Installing required Roslyn analyzers...
15:33:00.552  Processing plugin: csharp version 9.19.0.84025
15:33:00.553  Processing plugin: vbnet version 9.19.0.84025
15:33:00.561  Incremental PR analysis: Base branch parameter was not provided.
15:33:00.561  Cache data is empty. A full analysis will be performed.
15:33:00.59  WARNING: Multi-Language analysis is enabled. If this was not intended and you have issues such as hitting your LOC limit or analyzing unwanted files, please set "/d:sonar.scanner.scanAll=false" in the begin step.
15:33:00.63  Pre-processing succeeded.

@lxb Since the other topic isn’t that old and there’s recent activity from a responsible PM, I think it’s best the conversation continue on that other topic. I’ll close this one.

https://community.sonarsource.com/t/sonar-cloud-ignoring-rules-with-editorconfig-is-not-working/119701/13?u=colin

1 Like