BetaViberTest is in active development — expect breaking changes.
Overview
DocsRulesPoor Maintainability
#008mediumCode Quality

Poor Maintainability

Detects code patterns that hurt readability: long functions, too many params, magic numbers.

Rule ID:poor-maintainability

Examples#

BadLong function, many params, magic numbers
function processOrder(
  userId, productId, quantity, discount,
  taxRate, shippingMethod, couponCode, giftWrap
) {
  const price = getPrice(productId);
  const subtotal = price * quantity;
  const discounted = subtotal * (1 - discount);
  const tax = discounted * 0.19;           // magic number
  const shipping = shippingMethod === 'express' ? 15.99 : 5.99;
  const total = discounted + tax + shipping;
  if (total > 100) { /* free shipping logic... */ }
  if (couponCode === 'SAVE20') { /* coupon logic... */ }
  // ... 40 more lines
}
GoodOptions object, named constants, small functions
const TAX_RATE = 0.19;
const FREE_SHIPPING_THRESHOLD = 100;
const EXPRESS_SHIPPING = 15.99;
const STANDARD_SHIPPING = 5.99;

interface OrderOptions {
  userId: string;
  productId: string;
  quantity: number;
  discount: number;
  shippingMethod: 'standard' | 'express';
  couponCode?: string;
}

function processOrder(options: OrderOptions) {
  const subtotal = calculateSubtotal(options);
  const tax = subtotal * TAX_RATE;
  const shipping = getShippingCost(options.shippingMethod, subtotal);
  return { subtotal, tax, shipping, total: subtotal + tax + shipping };
}

What It Detects#

mediumFunction has too many parameters
"{funcName}" has {N} parameters (max: {max})

Fix: Use an options/config object pattern instead of positional parameters.

mediumFunction is too long
"{funcName}" is {N} lines long (max: {max})

Fix: Extract sub-functions with clear, descriptive names.

mediumFile has too many imports
File has {N} imports (max: {max})

Fix: Consider splitting into smaller, focused modules.

lowMagic number in code (not in allowed set)
Magic number {N} found

Fix: Extract to a named constant: const MAX_SOMETHING = {N};

lowSingle-letter variable name
Single-letter variable "{x}" is not descriptive

Fix: Use a descriptive name that explains the variable's purpose.

Configurable Thresholds#

OptionDefaultDescription
maxFunctionParams5Maximum function parameters
maxFunctionLines60Maximum lines per function
maxImports20Maximum imports per file

Configuration#

This rule is enabled by default. To disable it:

.vibertestrc.jsonjson
{
  "rules": {
    "poor-maintainability": {
      "enabled": false
    }
  }
}