swift-cognitive-complexity
Installation
SKILL.md
Swift Cognitive Complexity
Measure and reduce Cognitive Complexity in Swift code per G. Ann Campbell's paper (SonarSource, 2023).
Cognitive Complexity measures mental effort to understand code — not just path count (Cyclomatic Complexity). Deeply nested code costs more than flat code with the same branch count.
Arguments
The user provided: $ARGUMENTS
If a file path is given — read it. If no arguments — ask the user to paste the code or specify a file.
Scoring Rules
A — Structural increments (+1 each, plus nesting penalty)
These structures break linear flow and add nesting: