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

NuGet package should provide AllDisabled ruleset\config #709

Open
payn-git opened this issue Mar 18, 2024 · 7 comments
Open

NuGet package should provide AllDisabled ruleset\config #709

payn-git opened this issue Mar 18, 2024 · 7 comments

Comments

@payn-git
Copy link

Similar to Microsoft analyzers approach. NuGet package should always provide configuration for .ruleset and .config files with all rules listed as disabled. This is very often used on projects where project config derive from all disabled configuration and only individual rules required by project are enabled. Currently such all disabled ruleset have to be manually updated every time when new rule is included.. Simply replacing whole file with new version is much easier from maintenance point of view. As one doesn't need to spend time trying to figure out which rules was added to start with.

@mikkelbu
Copy link
Member

@payn-git Just to be sure I understand, but you mean something like this dotnet/roslyn-analyzers#1718 that provides a lot of rulesets?

image

@payn-git
Copy link
Author

Yes that's correct. Although, Im mostly interested only in AllDisabled variation of it as all projects are setup differently and I don't know anybody who have all enabled or all enabled per category etc. However, if all disabled\enabled\default version will be provided that would not harm anybody. Also please be aware that Microsoft provide both *.ruleset and also new *.config. In all our projects we use *.ruleset as that's more flexible than config files.

@manfred-brands
Copy link
Member

@payn-git Microsoft has deprecated rulesets. But I see they still supplies them with the analyzer.

Just out of interest, why do you think rulesets are more flexible? Is that because you can reference them conditionally?

At my work we use .globalconfig files to share configuration between projects.
They have similar format as .editorconfig and can be referenced in a Directory.Build.props like:

  <ItemGroup>
    <GlobalAnalyzerConfigFiles Include="$(NUnitAnalyzerConfigLocation)" />
  </ItemGroup>

@mikkelbu We should create these files automatically and check them in test to ensure new rules got added. Similar to what we for the documentation index.

@payn-git
Copy link
Author

Its about ruleset hierarchy itself. In my personal POV Microsoft did terrible job with *.EditroConfig files which work on folder hierarchy structure. In old ruleset we can enforce rulesets hierarchy from any locations by using include which is widely used in corporate big projects. So I can do something like this. As far as I know there is not direct inclusion possible with *.EditroConfig. There was request in Git for Microsoft to provide same ability instead of cluttering folder structure approach, but as far as I know it was never resolved. One of those things which was perfectly fine, but Microsoft had to change them to make things worse :).

@payn-git
Copy link
Author

Ruleset config example which was cut off from previous comment.
<RuleSet Name="AllDisabled" Description="AllDisabled ruleset makes sure all analyzers are disabled by default." ToolsVersion="15.0"> <Include Path=".\AllDisabledRulesets\codingBot.analyzers.ruleset" Action="Default"/> <Include Path=".\AllDisabledRulesets\projectSpecificanalyzers.ruleset" Action="Default"/> <Include Path=".\AllDisabledRulesets\microsoft.netanalyzers.ruleset" Action="Default"/> <Include Path=".\AllDisabledRulesets\microsoft.threading.ruleset" Action="Default"/> <Include Path=".\AllDisabledRulesets\nunit.analyzers.ruleset" Action="Default"/> </RuleSet>

@Bartleby2718
Copy link
Contributor

@mikkelbu @manfred-brands I have a related question: is it possible to enable all NUnit.Analyzers diagnostics but not other diagnostics/rules?

@manfred-brands
Copy link
Member

@Bartleby2718 I presume you don't want to see the default Microsoft Rules?
You can disable them by setting EnableNetAnalyzers to false.

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

No branches or pull requests

4 participants