complexitylisted
Install: claude install-skill dean0x/devflow
# Complexity Patterns
Domain expertise for code complexity and maintainability analysis. Use alongside `devflow:review-methodology` for complete complexity reviews.
## Iron Law
> **IF YOU CAN'T UNDERSTAND IT IN 5 MINUTES, IT'S TOO COMPLEX**
>
> Every function should be explainable to a colleague in under 5 minutes. If you need a
> diagram to understand control flow, refactor. If you need comments to explain what
> (not why), the code is too clever. Simplicity is a feature, complexity is a bug.
---
## Complexity Categories
### 1. Cyclomatic Complexity
High decision path count makes code hard to test and understand.
**Violation**: Deep nesting (5+ levels)
```typescript
if (order) {
if (order.items) {
for (const item of order.items) {
if (item.quantity > 0) {
if (item.product?.inStock) {
// Buried logic
```
**Solution**: Early returns and extraction
```typescript
function processOrder(order: Order) {
if (!order?.items) return;
for (const item of order.items) processItem(item);
}
function processItem(item: OrderItem) {
if (item.quantity <= 0 || !item.product?.inStock) return;
// Logic at top level
}
```
### 2. Readability Issues
Code that requires mental effort to parse.
**Violation**: Magic values
```typescript
if (status === 3) {
setTimeout(callback, 86400000);
}
```
**Solution**: Named constants
```typescript
const OrderStatus = { COMPLETED: 3 } as const;
const ONE_DAY_MS = 24 * 60 * 60 * 1000;
if (status === OrderStatus.C