Dead Code vs Zombie Code
Dead code is code that can never run — unused exports, unreachable branches, functions nobody calls. Zombie code runs, but for no reason: it is reached only by other unused code, so the whole cluster is effectively orphaned even though each piece looks used.
How each is detected
Dead code is found by static reachability: is this symbol referenced anywhere? If nothing imports or calls it, it is dead.
Zombie code needs a call-graph walk from the real entry points — routes, pages, scheduled jobs, CLI commands. A function can be called by another function and still be a zombie if nothing reachable ever calls the caller.
Why dead-code scanners miss zombie code
Most dead-code tools answer “is this referenced?”, not “is the thing that references it reachable?”. A mutually-recursive pair of unused functions references each other, so each looks used, and the whole island is missed.
Both matter for the same reasons: safe deletion, a smaller surface to reason about, and faster builds and tests.
Common questions
What is the difference between dead code and zombie code?
Dead code is never executed because nothing references it. Zombie code is executed, but only by other code that is itself unreachable, so the entire cluster serves no purpose.
How do you find zombie code in a repository?
Build the call graph, mark everything reachable from the real entry points (routes, pages, jobs, CLI), and then report the connected clusters that reference each other but that nothing reachable ever enters.
Is it safe to delete dead code?
Usually, but confirm first: check for dynamic references, reflection, and external callers that a static scan cannot see. A confidence score on each finding tells you which are safe to remove without further checking.
Related
- Dead code detection — Stop shipping code nobody uses. Mapnostics finds unused exports, functions and branches across your whole codebase, with a confidence score on every finding so you know what is actually safe to delete.
- Zombie code detection — Find zombie code that dead-code scanners miss: functions that call each other but that no route, page, job or CLI entry point ever reaches. Mapnostics walks the call graph from every real entry point and names the whole orphaned cluster.
- Dependency graph — glossary
- Codebase health score — glossary
See it in your own codebase.
Analyze my codebase →No credit card required · Free tier available