Skip to content

empty-statement

Javasuspiciousno fixdefault: warn

Reports a lone ; that is the body of an if or a loop, such as while (x);, on the ;.

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.

Reported
...
return s.equals("a");
}
while (done);
return false;
}
...
java:
lint:
rules:
empty-statement: warn # off, warn (default), error

Suppress one line with sudsy-disable-next-line empty-statement in a comment of the file’s language.

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.