A for loop has only a condition, like a while loop
What it finds
for (; running; ) is a while loop written with the wrong keyword: it has a condition and nothing else. The fix writes while (running). A for (;;) without a condition is a common way to write an endless loop and is left alone.
From the rule's source, for_as_while.rs.
class Loops { void run(java.util.Iterator<String> it) { for (; it.hasNext(); ) {tx0 reports: this for loop only has a condition it.next(); } for (;;) { break; } }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:for-as-while" = "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:for-as-while] reason="..."tx0 explain tx0/java:for-as-while shows the same in the terminal. Found a false positive? Report it.