Code quality and technical debt

Dead code

Also known as Dead code, Dead code in software engineering

By WeavePublished 1 min read

Definition

Code that cannot execute or whose result is never needed by the program.

What it means

Dead code includes unreachable branches, unused declarations, obsolete feature paths, and computations whose results are discarded. Removing it can lower cognitive load and reduce the surface area that must be tested or secured. The important question is whether the code is truly unreachable in supported configurations, not whether it appears unused in one local search.

Example

A feature flag may leave an old branch after a migration. A static checker reports no references, but the team first verifies generated clients, reflection, scripts, and release configuration before deleting it.

Limitations

Dead-code detection is vulnerable to dynamic references, plugin loading, generated files, and operational scripts. Removing code can also erase useful rollback paths or historical context. Confirm ownership and deployment assumptions before making deletion the default response.

How to use the signal

Weave can show whether dead-code cleanup arrives in focused changes or alongside unrelated work, and whether it affects review or rework signals. Use the repository’s analyzer and deployment records to establish reachability.

How this relates to Weave

Weave can show whether dead-code cleanup arrives in focused changes or alongside unrelated work, and whether it affects review or rework signals. Use the repository’s analyzer and deployment records to establish reachability.

Explore Engineering intelligence

Sources and further reading

  1. SonarSource code metrics and analysis documentation