Comprehension Debt

Functions over 80 lines, nested more than 5 levels deep, or with more than 5 parameters

infoAI Qualitycomprehension-debt

Why this matters

AI tools generate monolithic functions because they produce code in a single pass. Long functions with deep nesting are hard to read, test, and debug — even for the AI that wrote them.

Example

Flaggedlib/checkout.ts
export async function handleCheckout(userId: string, cartId: string, coupon: string | null, shipping: Address, billing: Address, payment: string, saveCard: boolean) {
  // ...and 150 lines of nested logic
}
Fixedlib/checkout.ts
interface CheckoutParams {
  userId: string;
  cartId: string;
  coupon?: string;
  shipping: ShippingDetails;
  billing: BillingDetails;
  payment: PaymentDetails;
}

export async function handleCheckout(params: CheckoutParams) {
  const cart = await validateCart(params.cartId);
  const totals = await calculateTotals(cart, params.coupon);
  const charge = await processPayment(totals, params.payment);
  return await createOrder(params, cart, charge);
}

How to fix

Break functions over 80 lines into smaller, named functions. Use an options object instead of many parameters. Extract nested logic into helper functions.

Reference

In the output
Findings carry "ruleId": "comprehension-debt" in --json and the same id in SARIF and in the terminal.
Silence one line
// prodlint-disable-next-line comprehension-debt
Silence a whole file
// prodlint-disable comprehension-debt at the top of the file
How it works
Matches text patterns. Source on GitHub