Unconditional loop

Background

Unconditional loops are very common in most code. However, in many cases they can be replaced by code that functions in a very similar way, but is more easily readable.
For an unconditional loop to be recognized, two conditions must be met:

Note: only local, non-volatile variables are considered. Field references and function calls are always considered to be undetermined - with the exception of final fields.

Since 0.6

Example

Bad code:

Good code:



while(true) {
   if (condition) {
      break;
   }
}
while(!condition) {
}


Requires bindings

This code check requires Eclipse to resolve bindings. Enabling this code check increases build time.