Back to Glossary
Code Review & Quality

Dead Code

Code that is never executed at runtime, including unreachable code, unused functions, and code hidden behind always-false conditions.

Definition

Dead code takes several forms: unreachable code (after return/throw), unused functions/classes, code behind feature flags that were never enabled, and zombie code (commented-out blocks kept "just in case"). It accumulates through feature removals, refactoring, and developer turnover. Static analysis tools, tree-shaking (webpack, rollup), and IDE warnings detect dead code. Some dead code is intentional (debug code, future features) and should be clearly marked.

Why It Matters

Dead code increases cognitive load, bundle sizes, and maintenance burden. Developers waste time reading and maintaining code that never runs. It can also hide security vulnerabilities or give false confidence in test coverage. Regular cleanup improves code health and developer productivity.

Example

A function sendLegacyEmail() was replaced by sendEmail() 2 years ago but never deleted. It's never called but developers still read it when searching for email logic. Static analysis flags it as unused, and deletion improves codebase clarity.

Related Terms

dead codeunused codedead code eliminationunreachable codecode cleanup

Automate Code Review with diffray

Multi-agent AI system for code review. Automatically finds bugs, security vulnerabilities, and architecture issues.