Dead Code (ARCH4188)
Key java.quality.dead-code · Severity info · Category quality
Statements after return, throw, break, or continue never execute and mislead the reader. Remove unreachable code.
Incorrect
Section titled “Incorrect”int compute(int x) { if (x > 0) { return x * 2; log.info("computed"); // unreachable } return 0;}Correct
Section titled “Correct”int compute(int x) { if (x > 0) { log.info("computed"); return x * 2; } return 0;}Delete unreachable statements, or reorder the control flow if the code is actually needed.