SlopScore for Code

Patterns / Unused helpers

Unused helpers

Ask an agent for a feature and you often get the feature plus three utilities it thought might be useful: a formatter, a validator, a retry wrapper. Some never get called. Unused code still needs reading, testing and maintaining, and it misleads the next person (or agent) about how the system works.

What it looks like

function formatInvoiceDate(d) { ... }   // referenced nowhere
def _normalize_payload(data): ...   # never called
const sleep = (ms) => new Promise(...)   // dead

Why it matters

Models plan ahead and over-scaffold, then the plan changes mid-generation. The leftovers stay because nothing breaks.

Before and after

Before
function formatInvoiceDate(d: Date) {
  return d.toISOString().slice(0, 10);
}

export async function getInvoices(id: string) { /* never uses it */ }
After
export async function getInvoices(id: string) { ... }

How to fix it

  1. Search the repo for each new function name. SlopScore for Code does this automatically for JS/TS, Python and Go, and for module-private functions in brand-new JS files even without repo access.
  2. Delete it. If it's needed later, it's in git history.
  3. For libraries, export it intentionally and add a test, so it's API rather than leftovers.

When it's fine

Exported library functions, decorated handlers (routes, fixtures, CLI commands) and framework hooks are skipped, because they're called by something outside the repo.

Catch this automatically. SlopScore for Code checks every pull request for this pattern (rule unused-helper) and 11 others. Score a public PR or add the free GitHub Action.

Related