Skip to content

Runs of statements that recur (after rename canonicalisation) in multiple files. Likely copy-paste — extract a shared helper. Canonicalisation maps identifier tokens to per-window local indices so renamed copies still match. Minimum window is 6 consecutive statements (and 80 characters) to keep noise low. Cross-file: per-file run writes fingerprints into the shared corpus; finalize groups by hash and emits one Issue per duplicate set with related spans pointing at every other occurrence.

ts
// src/orders.ts:42
const items = parseItems(input);
const validated = validateItems(items);
const priced = priceItems(validated, currency);
const taxed = applyTax(priced, region);
const total = sumItems(taxed);
return { items: taxed, total };
ts
// src/quotes.ts:88 — same shape, renamed: flagged as related
const products = parseItems(input);
const checkedProducts = validateItems(products);
const pricedProducts = priceItems(checkedProducts, currency);
const taxedProducts = applyTax(pricedProducts, region);
const total = sumItems(taxedProducts);
return { items: taxedProducts, total };
ts
// fix: extract once
export function pipeline(input: RawInput, currency: Currency, region: Region) {
  const items = parseItems(input);
  const validated = validateItems(items);
  const priced = priceItems(validated, currency);
  const taxed = applyTax(priced, region);
  return { items: taxed, total: sumItems(taxed) };
}

MIT License