|
1 | | -# Neolution Code Analysis rulesets |
2 | | -We maintain two (opinionated) rulesets for all our projects and distribute them, including 3rd-party Roslyn Analyzers (StyleCop and SonarSource) in two respective NuGet packages. |
| 1 | +# Neolution Code Analysis Rulesets |
3 | 2 |
|
4 | | -- For Libraries, Tools, Web, UI and other projects |
5 | | - - [Neolution.CodeAnalysis](https://www.nuget.org/packages/Neolution.CodeAnalysis/) |
6 | | -- For projects containing automated tests (less strict rules) |
7 | | - - [Neolution.CodeAnalysis.TestsRuleset](https://www.nuget.org/packages/Neolution.CodeAnalysis.TestsRuleset/) |
| 3 | +[](https://www.nuget.org/packages/Neolution.CodeAnalysis/) |
| 4 | +[](https://www.nuget.org/packages/Neolution.CodeAnalysis.TestsRuleset/) |
8 | 5 |
|
9 | | -## Decisions and opinions |
10 | | -The base ruleset consists of the default ruleset of the Roslyn Analyzers we include in the NuGet package and those used in our build tools. |
| 6 | +**Neolution.CodeAnalysis** provides a plug-and-play code analysis standard for .NET projects. By adding this package, you instantly enforce consistent, high-quality code with minimal setup—no need to maintain your own ruleset or configuration. The package includes: |
11 | 7 |
|
12 | | -- We include our own opinionated ruleset with adjusted Analyzer severities as a [Global AnalyzerConfig](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files#global-analyzerconfig) |
13 | | -- In all build configurations other that `Debug`, warnings will be converted to errors. |
14 | | -- We include our own [stylecop.json](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/Configuration.md) configuration file. |
| 8 | +- Pre-configured Roslyn analyzers (StyleCop, SonarSource) |
| 9 | +- Strict and up-to-date rules for code quality and security |
| 10 | +- Automatic conversion of warnings to errors (except in Debug) |
| 11 | +- A single source of truth for code style and best practices |
| 12 | +- Easy updates: just bump the package version to get the latest rules |
| 13 | + |
| 14 | +**Why use this package?** |
| 15 | + |
| 16 | +- Save time on code reviews by catching issues early |
| 17 | +- Ensure all projects follow the same standards |
| 18 | +- Reduce technical debt and improve maintainability |
| 19 | +- Onboard new developers faster with clear, enforced guidelines |
| 20 | +- **Flexible:** You can override any rules or severities in your own `.editorconfig` files at the project or solution level to fit your team's needs. |
| 21 | + |
| 22 | +## Packages |
| 23 | + |
| 24 | +- **[Neolution.CodeAnalysis](https://www.nuget.org/packages/Neolution.CodeAnalysis/):** For libraries, tools, web, UI, and other projects. |
| 25 | +- **[Neolution.CodeAnalysis.TestsRuleset](https://www.nuget.org/packages/Neolution.CodeAnalysis.TestsRuleset/):** For test projects (less strict rules). |
| 26 | + |
| 27 | +## Installation |
| 28 | + |
| 29 | +Install via NuGet Package Manager: |
| 30 | + |
| 31 | +```shell |
| 32 | +Install-Package Neolution.CodeAnalysis |
| 33 | +``` |
| 34 | + |
| 35 | +or for test projects: |
| 36 | + |
| 37 | +```shell |
| 38 | +Install-Package Neolution.CodeAnalysis.TestsRuleset |
| 39 | +``` |
| 40 | + |
| 41 | +Or add the following to your `.csproj`: |
| 42 | + |
| 43 | +```xml |
| 44 | +<ItemGroup> |
| 45 | + <PackageReference Include="Neolution.CodeAnalysis" Version="*"> |
| 46 | + <PrivateAssets>all</PrivateAssets> |
| 47 | + <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
| 48 | + </PackageReference> |
| 49 | +</ItemGroup> |
| 50 | +``` |
15 | 51 |
|
16 | 52 | ## Versioning |
17 | | -Given a version number `MAJOR.MINOR.PATCH`, an incremented number for: |
18 | 53 |
|
19 | | -- `MAJOR` version means there are incompatible changes with the previous version, |
20 | | -- `MINOR` version means functionality and rules were added, and |
21 | | -- `PATCH` version means that the changes are all completely backwards compatible. Usually when rules were lowered in severity or disabled/removed. |
| 54 | +- **MAJOR**: Incompatible changes, may require significant refactoring |
| 55 | +- **MINOR**: New rules or rule changes, may break the build |
| 56 | +- **PATCH**: Safe to update, only disables or lowers severity of rules |
| 57 | + |
| 58 | +See [CHANGELOG.md](./CHANGELOG.md) for details. |
| 59 | + |
| 60 | +## License |
| 61 | + |
| 62 | +This project is licensed under the [MIT License](./LICENSE). |
| 63 | + |
| 64 | +## Contributing |
| 65 | + |
| 66 | +Contributions, issues, and feature requests are welcome! Please open an issue or pull request on [GitHub](https://github.com/neolution-ch/Neolution.CodeAnalysis). |
| 67 | + |
| 68 | +> **Note:** The ruleset is intentionally opinionated and curated by Neolution to reflect our collective experience and values. While we welcome feedback and suggestions, changes to the rules themselves are carefully considered to maintain consistency across projects. If your requirements differ significantly, you are welcome to fork the package and adapt it to your needs. |
| 69 | +
|
| 70 | +## Links |
22 | 71 |
|
23 | | -### What it means in practice: |
24 | | -- You can (and should) always update the package to the latest `PATCH` version whenever you have the chance to do it, it should never break the build. |
25 | | -- Updating to the latest `MINOR` version can break the build and may require minor refactorings. But you can expect to have Roslyn code fixes and/or documentation available for the changes that are needed to fix the build. |
26 | | -- `MAJOR` updates will break your build and may require major refactorings. |
| 72 | +- [Source on GitHub](https://github.com/neolution-ch/Neolution.CodeAnalysis) |
| 73 | +- [NuGet: Neolution.CodeAnalysis](https://www.nuget.org/packages/Neolution.CodeAnalysis/) |
| 74 | +- [NuGet: Neolution.CodeAnalysis.TestsRuleset](https://www.nuget.org/packages/Neolution.CodeAnalysis.TestsRuleset/) |
0 commit comments