no-comment-before-block
What it does
Section titled “What it does”Reports a comment between the head of an if, else, while, do, for, foreach, lock, try, catch, finally, switch, checked or unchecked and its {.
Why it matters
Section titled “Why it matters”A comment there is attached to neither the head nor the block, and a reader may take it for a part of the condition. It is also easy to separate from its statement when the code is moved.
To fix, put the comment inside the block or above the statement.
Example
Section titled “Example”class A { void F(bool x, int y) { ;... while (x) /* c */ { } switch (y) { case 1: ; break; default: ; } L: ; int z = 1;;...Configuration
Section titled “Configuration”csharp: lint: rules: no-comment-before-block: warn # off (default), warn, errorEnabled by the presets: csharp/stylecop.
Suppress one line with sudsy-disable-next-line no-comment-before-block 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 | SA1108 |
full |