no-empty-statement
What it does
Section titled “What it does”Reports a lone ; that does nothing. A statement labelled label: ; is not reported. The fix removes the statement (its whole line when it is alone on it), or turns an empty loop or if body into { }; it is not offered for the only statement of a switch section. The compiler reports if (x); too.
Why it matters
Section titled “Why it matters”A stray ; is usually the result of a typo or an edit. After if (x); or while (x); it is the body of the statement, so the line that follows runs unconditionally, whatever its indentation says.
To fix, delete the ;, or write { } for a body that is meant to be empty.
Example
Section titled “Example”class A { void F(bool x, int y) { ; if (x); else { }... switch (y) { case 1: ; break; default: ; } L: ; int z = 1;;} }Configuration
Section titled “Configuration”csharp: lint: rules: no-empty-statement: warn # off (default), warn, errorEnabled by the presets: csharp/stylecop.
Suppress one line with sudsy-disable-next-line no-empty-statement in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| StyleCop | SA1106 |
full |