Open
Description
Prerequisites
- This rule has not already been suggested.
- This should be a new rule, not an improvement to an existing rule.
- This rule would be generally useful, not specific to my code or setup.
Suggested rule title
Unreachable code should be removed
Rule description
This rule would pick up simple statically verifiable cases of unreachable code, by raising an issue when encountering a statement immediately after the following (i.e. in the same block):
Exit
Break
Continue
raise
goto
As a gotcha, the rule must not raise an issue if the "dead" statement is a goto label, or contains a goto label nested inside it.
Rationale
Accidental unreachable code is a common problem when writing or refactoring code, and is at best messy and at worst an avenue for bugs and unexpected behaviour. Delphi also has no built in functionality to detect unreachable code, so this would fill a useful niche.