kurnakovv/kuker

GitHub: kurnakovv/kuker

kuker 是一个基于 Roslyn 的 C# 静态代码分析器,通过额外的专注规则帮助开发者编写更整洁、更健壮的代码。

Stars: 2 | Forks: 1

kuker

![访问者](https://api.visitorbadge.io/api/VisitorHit?user=kurnakovv&repo=kuker&countColor=%237B1E7A&style=flat) [![NuGet](https://img.shields.io/nuget/v/kurnakovv.kuker.svg)](https://www.nuget.org/packages/kurnakovv.kuker) [![NuGet 下载](https://img.shields.io/nuget/dt/kurnakovv.kuker.svg)](https://www.nuget.org/packages/kurnakovv.kuker) [![NuGet](https://img.shields.io/nuget/v/kurnakovv.kuker-preview.svg)](https://www.nuget.org/packages/kurnakovv.kuker-preview) [![NuGet 下载](https://img.shields.io/nuget/dt/kurnakovv.kuker-preview.svg)](https://www.nuget.org/packages/kurnakovv.kuker-preview) [![构建与测试](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/d56f00e820211032.svg)](https://github.com/kurnakovv/kuker/actions/workflows/build-and-tests.yml) [![.NET format](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/bd28626af3211038.svg)](https://github.com/kurnakovv/kuker/actions/workflows/dotnet-format.yml) [![InspectCode](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/968881241e211044.svg)](https://github.com/kurnakovv/kuker/actions/workflows/inspect-code.yml) [![PVS studio](https://custom-icon-badges.demolab.com/badge/pvs-studio-blue.svg?logo=codescan-checkmark&logoColor=white)](https://pvs-studio.com/en/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source) [![CodeQL](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/c0ec67ddcd211050.svg)](https://github.com/kurnakovv/kuker/actions/workflows/codeql.yml) [![Codecov](https://codecov.io/gh/kurnakovv/kuker/branch/dev/graph/badge.svg)](https://app.codecov.io/gh/kurnakovv/kuker) [![MIT License](https://img.shields.io/github/license/kurnakovv/kuker?color=%230b0&style=flat)](https://github.com/kurnakovv/kuker/blob/dev/LICENSE)
![line](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/2448d44253211056.gif) ## 📙 描述 👨‍🍳 kuker 是一款 C# 分析器,帮助你 ‍🍳 “kuk” ‍🔍 出美味且整洁的代码 😸 此分析器基于 [Roslyn API](https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/) | [教程](https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/tutorials/how-to-write-csharp-analyzer-code-fix) ## 🚀 快速开始 1️⃣ 通过 NuGet 安装 kuker: ``` dotnet add package kurnakovv.kuker ``` 此命令会将以下引用添加到你的项目中: ``` all runtime; build; native; contentfiles; analyzers; buildtransitive ``` 2️⃣ 构建项目: ``` dotnet build ``` 你可能会看到类似以下的输出: ``` PS D:\C#\JustApplication> dotnet build Restore complete (0.7s) JustApplication net8 succeeded with 7 warning(s) (3.5s) → JustApplication\bin\Debug\net8\JustApplication.dll D:\C#\JustApplication\JustApplication\Program.cs(2414,21): warning CS0219: The variable 'afdf' is assigned but its value is never used D:\C#\JustApplication\JustApplication\MyTest\MyTest.cs(1,1): warning KUK0002: The file name should match the name of one of the public or internal types: 'UserDto, TestClass, Point' (https://github.com/kurnakovv/kuker/wiki/KUK0002) D:\C#\JustApplication\JustApplication\Program.cs(2388,44): warning KUK0001: Argument 'a.MyTest.Ids' is passed multiple times to the same method call (https://github.com/kurnakovv/kuker/wiki/KUK0001) D:\C#\JustApplication\JustApplication\Program.cs(2390,48): warning KUK0001: Argument 'a.MyTest?.Ids' is passed multiple times to the same method call (https://github.com/kurnakovv/kuker/wiki/KUK0001) D:\C#\JustApplication\JustApplication\MyTest\MyTest.cs(20,41): warning KUK0003: 'Max' on a sequence of non-nullable value types may throw InvalidOperationException if the sequence is empty. Use a nullable selector or DefaultIfEmpty(). (https://github.com/kurnakovv/kuker/wiki/KUK0003) D:\C#\JustApplication\JustApplication\MyTest\MyTest.cs(23,38): warning KUK0003: 'MaxAsync' on a sequence of non-nullable value types may throw InvalidOperationException if the sequence is empty. Use a nullable selector or DefaultIfEmpty(). (https://github.com/kurnakovv/kuker/wiki/KUK0003) D:\C#\JustApplication\JustApplication\Program.cs(2393,34): warning KUK0001: Argument '(Test)a' is passed multiple times to the same method call (https://github.com/kurnakovv/kuker/wiki/KUK0001) Build succeeded with 7 warning(s) in 4.6s ``` 就是这样——kuker 现已启动并运行。祝你编码愉快!🚀 ## ⚙️ 配置 你可以通过 `.editorconfig` 文件配置所有规则 ``` [*.cs] ## ## kuker ## # 文档请见 https://github.com/kurnakovv/kuker # 设置所有具有 global category 的规则 dotnet_analyzer_diagnostic.category-KukerAllRules.severity = warning dotnet_diagnostic.KUK0001.severity = warning # Duplicate arguments passed to method | https://github.com/kurnakovv/kuker/wiki/KUK0001 dotnet_diagnostic.KUK0002.severity = warning # File name mismatch | https://github.com/kurnakovv/kuker/wiki/KUK0002 dotnet_diagnostic.KUK0003.severity = warning # Min/Max (Async) and MinBy/MaxBy may throw InvalidOperationException on empty sequences | https://github.com/kurnakovv/kuker/wiki/KUK0003 dotnet_diagnostic.KUK0004.severity = warning # Avoid primary constructor | https://github.com/kurnakovv/kuker/wiki/KUK0004 dotnet_diagnostic.KUK0005.severity = warning # .TagWithCallSite() on EF Core query execution | https://github.com/kurnakovv/kuker/wiki/KUK0005 dotnet_diagnostic.KUK0001.excluded_methods = Foo,Bar # Optional | Ignore selected methods # ... ``` 有关配置的更多信息,请访问我们的 [wiki](https://github.com/kurnakovv/kuker/wiki) ## ❔ 原因 .NET 生态系统提供了许多强大的分析器,包括诸如 [CAxxxx](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/categories?view=visualstudio) 和 [IDExxxx](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/?view=visualstudio) 等内置分析器,以及基于 [Roslyn API](https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/) 的知名第三方分析器,例如 [Roslynator](https://josefpihrt.github.io/docs/roslynator/) 和 [StyleCop](https://github.com/DotNetAnalyzers/StyleCopAnalyzers)。 尽管它们覆盖面很广,但某些规则仍未被覆盖。👨‍🍳 kuker 分析器旨在通过提供额外的、高度专注的分析规则来填补这些空白。 ## ⭐ 点个 Star 我希望这个分析器对你有用,如果是的话,请给这个仓库点个 star,谢谢 :) ## SAST 工具 [PVS-Studio](https://pvs-studio.com/en/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source) - 用于 C、C++、C# 和 Java 代码的静态分析器。
标签:NuGet, SOC Prime, 云安全监控, 代码分析, 凭证管理, 多人体追踪, 开发工具, 静态分析