A return or continue is the last statement of its body and changes nothing
What it finds
return; at the end of a void method and continue; at the end of a loop body are what happens anyway; they only add a line that readers stop at.
Reported is a return without a value as the last statement of a method, constructor or lambda body, and a continue without a label as the last statement of a loop body. The fix removes the statement.
From the rule's source, redundant_jump.rs.
class Jumps { void run(int[] values) { for (int value : values) { System.out.println(value); continue;tx0 reports: the last statement of the loop } System.out.println("done"); return;tx0 reports: this return is the last statement } void other(boolean flag) { if (flag) { return; } System.out.println(flag); }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:needless-final-jump" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:needless-final-jump] reason="..."tx0 explain tx0/java:needless-final-jump shows the same in the terminal. Found a false positive? Report it.