Dead-Code Flags Can Mask Missing Validation, Not Just Unused Variables
A developer auditing their codebase found six constants flagged as orphans by a dead-code detector, but none were actually unused — each served as a specification for valid values that the code failed to enforce. In two cases, the absence of validation meant typos in config-parsed strings could bypass critical logic gates, such as marking unconfirmable evidence as publishable or elevating a machine-generated answer to human status. The root issue was that 'zero references outside the defining file' is ambiguous: it can mean dead code to be deleted, or missing enforcement where a check should exist but doesn't. The author argues these two cases are indistinguishable from reference counts alone and that the second scenario is the more dangerous one because it creates a false impression that rules are being enforced. The fix applied in both cases was to treat unrecognized values as failures rather than defaults, on the principle that a broken value is not the same as an absent one.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in