Remove Dead Code

Referenced by patterns
Symptom

Functions, branches, fields, or imports that no static analysis or human reader can reach — last commented out, last touched years ago, or referenced only by code that itself was removed.

Goal

Every line in the codebase is reachable and used; readers don't waste cycles on phantom branches.

Before the refactoring

function legacyDiscount(order) { /* unused since 2018 */ }
function modernDiscount(order) { /* the real one */ }

After the refactoring

function discount(order) { /* the real one */ }
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure

Readers spend cycles understanding code that never runs; debuggers stop in places that look meaningful but aren't; refactoring proposals have to consider phantom users.

Tradeoff

The team gives up the option to revive without a git dive — and 'dead' under static analysis can still be reachable via reflection, dynamic dispatch, or external callers.

Relief

Smaller surface, faster reading, fewer false leads when debugging.

Trap

Deleting code that looks dead but is reached via reflection, dynamic dispatch, external callers, or test fixtures — the cleanup ships a regression because static analysis lied.