تخطَّ إلى المحتوى

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.

int compute(int x) {
if (x > 0) {
return x * 2;
log.info("computed"); // unreachable
}
return 0;
}
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.