Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable all rules by default #780

Closed
Otiel opened this issue Jan 7, 2025 · 2 comments · Fixed by #781
Closed

Disable all rules by default #780

Otiel opened this issue Jan 7, 2025 · 2 comments · Fixed by #781

Comments

@Otiel
Copy link

Otiel commented Jan 7, 2025

I'd like to disable all rules by default in my .editorconfig, then enable some rules specifically. Is this possible to do without having to list every rule to disable (that would also require me to maintain the .editorconfig file when updating if there are new analyzers)?

What I can do today :

[*.cs]

# Disable all Meziantou rules by default
dotnet_diagnostic.MA0001.severity = none
dotnet_diagnostic.MA0002.severity = none
dotnet_diagnostic.MA0003.severity = none
...
dotnet_diagnostic.MA0163.severity = none
dotnet_diagnostic.MA0164.severity = none
dotnet_diagnostic.MA0165.severity = none

# Enable Meziantou rules I want to use
dotnet_diagnostic.MA0042.severity = error

But instead I'd like to have something along:

[*.cs]

# Disable all Meziantou rules by default
dotnet_diagnostic.Meziantou.severity = none # This is not possible

# Enable Meziantou rules I want to use
dotnet_diagnostic.MA0042.severity = error

For instance, Roslynator offers to change the severity of all rules using:

dotnet_analyzer_diagnostic.category-roslynator.severity = default|none|silent|suggestion|warning|error
@meziantou
Copy link
Owner

This is not possible to use the same strategy as Roslynator as it would require changing the rule's categories, which is a breaking change. So, I choose a strategy similar to .NET. You can use the following property in the csproj to disable all rules by default.

<Project>
  <PropertyGroup>
    <MeziantouAnalysisMode>None</MeziantouAnalysisMode>
  </PropertyGroup>
</Project>

@Otiel
Copy link
Author

Otiel commented Jan 14, 2025

Perfect, and very prompt!

Thanks a lot. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants