Skip to content

Files

Latest commit

 

History

History
27 lines (18 loc) · 655 Bytes

whitespace-empty_loop_body.md

File metadata and controls

27 lines (18 loc) · 655 Bytes

Pattern: Use of ; for empty loop

Issue: -

Description

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.

Further Reading