dart-cognitive-complexity
Installation
SKILL.md
1. When to Use This Skill
Use this skill when analyzing Dart and Flutter codebase maintainability, evaluating function readability, or remediating high-complexity findings during code review or static analysis audits.
Unlike Cyclomatic Complexity (which linearly counts control flow branching paths and punishes declarative table switches), Cognitive Complexity measures the mental friction required for a human engineer to read and simulate control flow. Rely on deterministic evaluation to target structures matching these indicators:
- Deeply Nested Control Flow: Functions exhibiting multiple layers of enclosing
conditionals (
if,for,while), where horizontal indentation obscures logic. - Convoluted Conditional Trees: Functions employing verbose
if-elseorelse ifchains instead of modern Dart 3 exhaustive pattern matching or table-driven switch expressions. - Monolithic Method Bodies: Functions breaching operational threshold ceilings.
- God Classes: Logic classes exceeding structural line-count targets
(excluding declarative Flutter
buildmethods).