Pattern: Use of ;
for empty loop
Issue: -
Empty loop bodies should use {}
or continue
, but not a single semicolon.
Example of incorrect code:
while (condition); // Bad - looks like part of do/while loop.
Example of correct code:
while (condition) {
// Repeat test until it returns false.
}
for (int i = 0; i < kSomeNumber; ++i) {} // Good - one newline is also OK.
while (condition) continue; // Good - continue indicates no logic.