Monkey Patching
Modifying built-in prototypes and global objects at runtime
Code quality antipatterns donβt cause immediate failures but make the codebase:
Monkey Patching
Modifying built-in prototypes and global objects at runtime
Magic Numbers
Unexplained numeric literals scattered throughout code
Callback Hell
Deeply nested callbacks and mixed async patterns
God Middleware
Single middleware handling too many responsibilities
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Technical Debt Growth ββ ββ Time to add features ββ β ββ β β±β±β± ββ β β±β±β±β± ββ β β±β±β±β± ββ β β±β±β±β± ββ β β±β±β±β± ββ β β±β±β±β± ββ β β±β±β±β± ββ β β±β±β±β± ββ ββββββββββββββββββββββββββββββββββββββββββββββββββ ββ Codebase age β ββ ββ Without refactoring, every new feature takes longer ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// Bad: Clever one-linerconst r = a.reduce((p, c) => (p[c.t] = (p[c.t] || 0) + c.v, p), {})
// Good: Readable logicconst totals = {}for (const item of items) { const type = item.type totals[type] = (totals[type] || 0) + item.value}// Bad: Magic behaviorconst user = getUser() // What if it returns null? Throws? Caches?
// Good: Explicit contractconst user = await userService.findById(id)if (!user) { throw new NotFoundError(`User ${id} not found`)}// Bad: Function does everythingfunction processOrder(order, user, inventory, payment, email) { // 500 lines of mixed concerns}
// Good: Focused functionsfunction validateOrder(order) { /* ... */ }function checkInventory(items) { /* ... */ }function processPayment(payment) { /* ... */ }function sendConfirmation(email, order) { /* ... */ }// Bad: Continue with bad datafunction processUser(user) { const name = user?.name || 'Unknown' const email = user?.email || '' // Silently continues with garbage data}
// Good: Validate earlyfunction processUser(user) { if (!user) throw new Error('User is required') if (!user.name) throw new Error('User name is required') if (!user.email) throw new Error('User email is required') // Now we know we have valid data}| Metric | Healthy | Warning | Critical |
|---|---|---|---|
| File lines | < 200 | 200-500 | > 500 |
| Function lines | < 30 | 30-60 | > 60 |
| Cyclomatic complexity | < 10 | 10-20 | > 20 |
| Nesting depth | < 3 | 3-5 | > 5 |
| Parameters | < 4 | 4-6 | > 6 |