empty-statement
What it does
Section titled “What it does”Reports a lone ; that is the body of an if or a loop, such as while (x);, on the ;.
Why it matters
Section titled “Why it matters”The semicolon ends the statement, so the code that follows on the next line is not the body of the loop, whatever its indentation says. It is a typical typo, and the loop either does nothing or never ends.
To fix, delete the ;, or write {} if an empty body is meant.
Example
Section titled “Example”... return s.equals("a"); } while (done); return false; }
...Configuration
Section titled “Configuration”java: lint: rules: empty-statement: warn # off, warn (default), errorSuppress one line with sudsy-disable-next-line empty-statement in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| checkstyle | EmptyStatement |
partial | Only the body of an if or a loop. |