Skip to main content

Software Development

Code Complexity Auditor

Scores functions on cyclomatic complexity, cognitive load, and length, then flags thresholds exceeded and suggests refactoring into smaller testable units. Useful for preventing maintenance debt from rapidly generated code. Tech leads reviewing AI-assisted PRs, engineers maintaining code they did not originally write, platform teams enforcing a complexity budget across a portfolio of services. The most insidious failure mode is not broken code but unmaintainable code — 120-line functions with nested conditionals and eight parameters that work today but become expensive to debug in three months. Static complexity metrics catch these cases reliably, but most teams do not run them consistently. A pre-review auditor flags the functions most likely to accumulate technical debt and proposes specific decompositions.

Nexus CertifiedClaude CodeCodexOpenClawGoogle Antigravity
code-qualitycomplexityrefactoringmaintainabilitytechnical-debt

One-Time Purchase

$19.99

Sample Output

Complexity Audit — src/services/checkout.ts

Functions scanned: 14 · Thresholds: cyclomatic 10, cognitive 15, params 5, length 60

Verdict

Refactor required before next merge. Three functions exceed cyclomatic 10, two exceed cognitive 15, and processCheckout is a 148-line god-function carrying inventory, coupons, tax, payment, and order persistence. One justifiable exception (resolvePaymentRouting) is documented below.

Hotspots (worst first)

`processCheckout` — cyclomatic 23, cognitive 34, 148 linesCRITICAL
`applyDiscountRules` — 6 parameters, cyclomatic 17HIGH
`buildOrderSummary` — 74 lines, low branchingMEDIUM
`resolvePaymentRouting` — accepted (compliance state machine)EXCEPTION

Findings

FunctionCyclomaticCognitiveParamsLengthSeverity
processCheckout23343148Critical
applyDiscountRules1721654High
buildOrderSummary89474Medium
resolvePaymentRouting1914258Exception
reservePaymentMethod78341OK
emitOrderEvents66238OK

processCheckout Critical

A single function body handles inventory validation, coupon stacking, tax, payment dispatch, and order record creation. The nested coupon-stacking conditionals alone contribute 11 cyclomatic points. Test coverage on this function is currently 41%, and three of the last five production incidents on checkout traced back here.

Refactor. Decompose into five focused functions. Each extracted function preserves the return type and side-effect contract of the corresponding block, so the public signature is unchanged.

Before

One 148-line function

Inventory + coupons + tax + payment + persistence inline

cyclomatic complexity23
cognitive complexity34
lines148
41%unit test coverage

After

One orchestrator + five helpers

Each helper is independently testable

cyclomatic (orchestrator)1
cognitive (orchestrator)3
lines per helper~25
≥90%target coverage
// AFTER
async function processCheckout(cart: Cart, user: User, options: CheckoutOptions): Promise<OrderResult> {
  await validateInventory(cart);
  const discountedCart = await applyCoupons(cart, options.couponCodes);
  const taxedCart = await applyTax(discountedCart, user.address);
  const paymentResult = await dispatchPayment(taxedCart, user.paymentMethod);
  return createOrderRecord(taxedCart, user, paymentResult);
}

async function validateInventory(cart: Cart): Promise<void> {
  for (const item of cart.items) {
    const stock = await inventoryService.getStock(item.sku);
    if (stock < item.quantity) {
      throw new InsufficientStockError(item.sku, stock, item.quantity);
    }
  }
}

async function applyCoupons(cart: Cart, codes: string[]): Promise<Cart> {
  let discounted = { ...cart };
  for (const code of codes) {
    const coupon = await couponService.resolve(code);
    discounted = coupon.apply(discounted);
  }
  return discounted;
}

applyDiscountRules High

Six positional parameters (loyaltyTier, promoCode, isEmployee, cartTotal, itemCount, regionCode) and three levels of nested coupon-stacking logic. The parameter list alone is a maintenance trap — call sites have already swapped arguments twice in the past 90 days according to git blame.

Refactor. Introduce a DiscountContext value object and a tier-rate map. Keep the original signature as a thin shim so call sites do not change.

interface DiscountContext {
  loyaltyTier: string;
  promoCode: string | null;
  isEmployee: boolean;
  cartTotal: number;
  itemCount: number;
  regionCode: string;
}

function applyDiscountRulesFromContext(ctx: DiscountContext): number {
  const base = resolveBaseDiscount(ctx);
  const promo = resolvePromoDiscount(ctx.promoCode, ctx.cartTotal);
  return Math.min(base + promo, ctx.cartTotal);
}

function resolveBaseDiscount(ctx: DiscountContext): number {
  if (ctx.isEmployee) return ctx.cartTotal * 0.20;
  const rates: Record<string, number> = { gold: 0.15, silver: 0.10, bronze: 0.05 };
  return ctx.cartTotal * (rates[ctx.loyaltyTier] ?? 0);
}

Estimated after refactor: cyclomatic 2, cognitive 2.

buildOrderSummary Medium

Exceeds length threshold (74 lines) but branching is flat and linear. Low incident risk, but extraction improves readability and unit-test isolation for the currency and address formatters.

Refactor. Extract formatCustomerName, formatAddress, formatLineItem, formatTotals. No behavioral change.

resolvePaymentRouting Justifiable Exception

Cyclomatic 19 encodes a 16-rule gateway-selection state machine driven by regional financial compliance. Each branch maps to a documented regulatory citation. Cognitive complexity stays at 14 (below threshold) because the branching is structurally flat — a single switch on regionCode + paymentMethodKind. Decomposing would scatter the rule set across files and raise the risk of inconsistent updates when a rule changes.

Action. No refactor. Add a rule-table comment block above the function mapping each branch to its compliance reference.


Recommended Refactor Order

Sequence (highest leverage first)

Split `processCheckout` — unblocks coverage gains across the file1
Collapse `applyDiscountRules` params into `DiscountContext`2
Extract formatters from `buildOrderSummary`3
Document `resolvePaymentRouting` exception inline4

Before / After Summary

FunctionBeforeAfter Refactor
processCheckout23 / 34 / 1481 / 3 / 18
applyDiscountRules17 / 21 / 6 params2 / 2 / 1 param
buildOrderSummary8 / 9 / 743 / 3 / 22
resolvePaymentRouting19 / 14 / 58Exception (no change)
File-level worst casecyclomatic 23cyclomatic 3 (excl. exception)

This audit reviews a hypothetical file for illustration. Run the proposed changes behind a feature-flagged checkout shadow before retiring the original code path.

This sample illustrates the skill's output format. Names, metrics, and operational details are illustrative unless the artifact explicitly analyzes public information.

View full sample →

All sales final. No refunds on digital products.

Includes support for Claude Code, Codex, OpenClaw, and Google Antigravity in the same license.

Also in Specs & Governance

Bundle price: $55. Compare this skill with the full workflow bundle or Pro access.

Best for

Engineering leads conducting structured code-quality reviews on a service before a refactor decision, tech leads producing a complexity-debt view to justify a refactor sprint to product, and engineering managers monitoring complexity trends across a codebase as part of the quarterly health view. Most valuable on services with 10K-200K lines where complexity has accumulated unevenly and the team needs a defensible list of the worst offenders before deciding what to refactor.

Not ideal for

Greenfield or very small codebases where complexity is not yet meaningful. Also a poor fit as a substitute for actually deciding which complexity is worth fixing; the auditor surfaces complexity hotspots, but the call on which ones are real debt vs essential complexity still requires engineering judgment.

Included in this purchase

  • Claude Code, Codex, OpenClaw, and Google Antigravity skill files.
  • Setup guidance for the right adapter in your workspace.
  • One-time license for the purchased skill version.

Setup

Plan for a short setup in the repository or workspace where the skill will run. Some coding familiarity helps for implementation-heavy outputs.

Claude CodeCodexOpenClawGoogle Antigravity

Related Skills

Code Generation & Review
Featured
Code Generation
Generates, reviews, debugs, and executes code in sandboxed workflows. Useful for implementation, refactoring, and technical problem solving.
Claude CodeCodexOpenClawGoogle Antigravity
codingdebuggingcode-review

$19.99

One-time license

View Skill
Product Documentation & Onboarding
API Documentation Generator
Generates structured, developer-ready API documentation from code, OpenAPI specs, route definitions, or descriptions. Produces reference docs, quickstart guides, error references, and code examples.
Claude CodeCodexOpenClawGoogle Antigravity
apidocumentationdeveloper-experience

$19.99

One-time license

View Skill
Code Generation & Review
Intelligent PR Composer
Generates pull request descriptions that capture context, alternatives considered, test plan, risk areas, and reviewer guidance beyond a simple diff summary. Useful for teams that want senior-quality PRs without manual authoring.
Claude CodeCodexOpenClawGoogle Antigravity
pull-requestscode-reviewgit

$19.99

One-time license

View Skill

Future Updates

This purchase includes the current version of the skill. If you want future adapter updates — meaning compatibility and packaging updates as supported platforms evolve — plus new catalog additions included automatically, upgrade to Pro.

Upgrade to Pro