complexity

Configure .NET maintainability analyzers and code metrics thresholds to detect complex methods.

Updated May 2, 2026
One-click install
npx skills add https://github.com/hdeshev/pi-config --skill complexity-hdeshev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: complexity
Source: https://github.com/hdeshev/pi-config/tree/main/agent/skills/complexity
Command: npx skills add https://github.com/hdeshev/pi-config --skill complexity-hdeshev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Teams struggle to identify overly complex methods and enforce maintainability standards in .NET codebases without paid tooling. This Skill configures the free built-in .NET analyzers (CA1502, CA1505, CA1506, CA1501) with versioned thresholds so complexity issues surface in builds and CI. ## Core Features & Use Cases - Complexity Detection: Uses CA1502 for cyclomatic complexity, CA1505 for maintainability index, CA1506 for class coupling, and CA1501 for inheritance depth. - Versioned Thresholds: Keeps rule severities in the root .editorconfig and numeric limits in a checked-in CodeMetricsConfig.txt wired as AdditionalFiles. - CI Enforcement: Integrates with dotnet build and WarningsAsErrors so complexity gates run in pipelines. - Use Case: A team wants a cyclomatic complexity gate in CI. The Skill detects current analyzer state, adds severity entries and thresholds, runs dotnet build, and reports status with verification evidence. ## Quick Start Ask the agent to add a cyclomatic complexity gate with checked-in thresholds to your .NET solution and verify it with a build.

Frequently Asked Questions about complexity

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Which analyzer finds overly complex methods in .NET?▼

CA1502 is the built-in .NET analyzer rule that flags excessive cyclomatic complexity in methods. Related rules include CA1505 for low maintainability index, CA1506 for excessive class coupling, and CA1501 for deep inheritance.

How do I configure cyclomatic complexity thresholds in .NET?▼

Set rule severity in the root .editorconfig (e.g., dotnet_diagnostic.CA1502.severity = warning) and numeric thresholds in a checked-in CodeMetricsConfig.txt file included as AdditionalFiles in your project or Directory.Build.props.

Does this require paid third-party analysis tools?▼

No. The maintainability rules are first-party .NET analyzers included free with the .NET SDK for SDK-style projects targeting .NET 5 or later. Older projects can reference the Microsoft.CodeAnalysis.NetAnalyzers NuGet package.

How do I enforce complexity rules in CI builds?▼

Run dotnet build with -warnaserror, or promote only complexity rules to errors via the WarningsAsErrors property listing CA1502, CA1505, and CA1506. Thresholds stay versioned in the repo rather than in IDE settings.

When should I not use these complexity analyzers?▼

Avoid them for formatting-only work or generic analyzer setup with no complexity policy change. They also add little value when a team only wants stylistic linting and does not intend to act on maintainability findings.