low-complexitylisted
Install: claude install-skill mryll/skills
# Low Complexity Code
Every function/method written or modified MUST target:
- **Cognitive Complexity <= 5** (SonarSource metric). Acceptable up to 10 for inherently complex logic. Never exceed 15.
- **Cyclomatic Complexity <= 5**. Acceptable up to 10. Never exceed 15.
For full scoring rules, see [cognitive-complexity-spec.md](references/cognitive-complexity-spec.md).
## Cognitive Complexity Quick Reference
**+1 for each:** `if`, ternary (`? :`), `switch` (whole), `for`, `while`, `do while`, `catch`, `else if`, `else`, `goto LABEL`, `break/continue LABEL`, each method in a recursion cycle, each sequence of like boolean operators (`&&` / `||`).
**+1 nesting penalty** on top of structural increment for: `if`, ternary, `switch`, `for`, `while`, `catch` — when nested inside another flow-break structure.
**Free (no increment):** method calls, `try`, `finally`, `case` labels, null-coalescing (`?.`, `??`), early `return`, simple `break`/`continue`, lambdas (but lambdas increase nesting level).
## Cyclomatic Complexity Quick Reference
+1 for the method entry, +1 for each: `if`, `else if`, `for`, `while`, `do while`, `case`, `catch`, `&&`, `||`, ternary `?`. Core definition; some analyzers may vary by language.
## Mandatory Reduction Techniques
Apply these in order of preference:
1. **Extract method/function** — Move a coherent block into a named function. Resets nesting to 0. First choice when the extracted block forms a coherent unit.
2. **Early return / guard clause** —