Loop variable not updated inside loop
Reports any variables and parameters that are used in a loop condition and are not updated inside the loop.
Such variables and parameters are usually used by mistake as they may cause an infinite loop if they are executed.
Example:
void loopDoesNotLoop(boolean b) {
while (b) {
System.out.println();
break;
}
}
Configure the inspection:
Use the Ignore possible non-local changes option to disable this inspection if the condition can be updated indirectly (e.g. via the called method or concurrently from another thread).
Inspection options
Option | Type | Default |
---|---|---|
Ignore possible non-local changes | Checkbox | true |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023