skillfed

complexity

complexity sets up .NET's built-in maintainability analyzers to enforce cyclomatic complexity and coupling limits across your codebase. It configures CA1502, CA1505, and CA1506 rules in .editorconfig and CodeMetricsConfig.txt, then validates thresholds through the build pipeline.

complexity configures cyclomatic complexity thresholds and maintainability analyzers for .NET projects using built-in CA rules.

AI-generated summary based on this skill's SKILL.md

463 35 MIT updated by managedcode

Install

managedcode/dotnet-skills/complexity · repository language: C#

git clone https://github.com/managedcode/dotnet-skills
cp -r dotnet-skills/catalog/Tools/Complexity/skills/complexity ~/.claude/skills/complexity
npx skillfed install managedcode/dotnet-skills/complexity

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How to find overly complex methods in .NET?

complexity enables .NET's built-in maintainability analyzers to automatically detect methods exceeding your cyclomatic complexity thresholds. Configure rule CA1502 in your .editorconfig file to flag methods that are too complex, then run your build to surface violations. The analyzer scans your entire C# codebase and reports problematic methods by file and line number, helping you prioritize refactoring efforts.

What are cyclomatic complexity thresholds and how do I set them in C#?

complexity manages cyclomatic complexity thresholds through .editorconfig and CodeMetricsConfig.txt. Rule CA1502 controls method complexity limits, CA1505 tracks maintainability index, and CA1506 monitors class coupling. Set your desired thresholds in .editorconfig (e.g., `dotnet_diagnostic.CA1502.severity = warning`), then validate them in your CI pipeline to enforce code quality gates across your .NET project.

How do I configure code complexity analyzers for dotnet?

complexity configures .NET's maintainability analyzers by adding rules to your .editorconfig file. Enable CA1502 (cyclomatic complexity), CA1505 (maintainability index), and CA1506 (class coupling), then set severity levels and thresholds. You can also use CodeMetricsConfig.txt for advanced configuration. Once configured, the analyzers run automatically during build and report violations in your IDE and build logs.

How can I set up code metrics gates in my CI pipeline?

complexity enforces complexity policies in CI by configuring your .editorconfig to treat analyzer violations as errors or warnings. Set rule severities to `error` to fail the build when thresholds are exceeded. Integrate the build step into your pipeline so that any commit violating your cyclomatic complexity, maintainability index, or coupling limits is caught before merge, maintaining consistent code quality standards.

What's the best way to reduce method complexity in a C# project?

complexity identifies complex methods so you can refactor them systematically. Use CA1502 violations to pinpoint high-complexity methods, then break them into smaller, focused functions. Address CA1506 class coupling warnings by extracting dependencies and applying dependency injection. Monitor CA1505 maintainability index trends as you refactor, and validate improvements by re-running the analyzers to confirm thresholds are met.

How do I bootstrap missing complexity rules and thresholds in editorconfig?

complexity helps you add complexity rules to .editorconfig by defining CA1502, CA1505, and CA1506 with appropriate severity and threshold settings. Start with recommended defaults, then tune thresholds based on your team's standards. Use CodeMetricsConfig.txt for granular per-project configuration. Once rules are in place, the analyzers activate automatically on next build, surfacing any existing violations for remediation.

SKILL.md

rendered from the published skill — quoted content, verbatim

.NET Complexity Review

Trigger On

  • the team wants to find overly complex methods
  • cyclomatic complexity thresholds are needed in CI
  • maintainability metrics or coupling thresholds need to be configured

Value

  • produce a concrete project delta: code, docs, config, tests, CI, or review artifact
  • reduce ambiguity through explicit planning, verification, and final validation skills
  • leave reusable project context so future tasks are faster and safer

Do Not Use For

  • formatting-only

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 5 files
catalog/Tools/Complexity/skills/complexity/SKILL.md
catalog/Tools/Complexity/skills/complexity/manifest.json
catalog/Tools/Complexity/skills/complexity/references/complexity.md
catalog/Tools/Complexity/skills/complexity/references/config.md
catalog/Tools/Complexity/skills/complexity/references/metrics.md

Related skills

Tags

code-metrics static-analysis refactoring-guidance build-gates design-debt quality-thresholds coupling-analysis inheritance-depth ci-integration