An empty code block is confusing. It will require some effort from maintainers to determine if it is intentional or indicates the implementation is
incomplete.
for (int i = 0; i < 42; i++){} // Noncompliant: is the block empty on purpose, or is code missing?
Removing or filling the empty code blocks takes away ambiguity and generally results in a more straightforward and less surprising code.
Exceptions
The rule ignores:
- code blocks that contain comments
-
while
loops
while (order.processNext()); // Compliant by exception