max-depth
ProComplexityEnforce a maximum nesting depth to catch AI-generated deeply nested code
max-depth
Enforce a maximum nesting depth to catch AI-generated deeply nested code
Category: Complexity | Tier: Pro
Why This Matters
AI generates deeply nested code structures -- loops inside conditions inside loops. Each level of nesting makes the code exponentially harder to reason about and increases the chance of logic errors.
Bad Code
// Deeply nested code is hard to reason about
if (user) {
if (user.profile) {
if (user.profile.settings) {
if (user.profile.settings.theme) {
applyTheme(user.profile.settings.theme);
}
}
}
}
Good Code
// Use optional chaining and early returns
const theme = user?.profile?.settings?.theme;
if (theme) {
applyTheme(theme);
}
Configuration
This rule wraps max-depth. See upstream documentation for full configuration options.