BRO1120: Comments should contain text¶
An empty comment at the start or end of a comment (or on its own) is removed. Replaces StyleCop SA1120.
Example¶
Before¶
public class Report
{
public int Total()
{
//
// Sums the lines.
//
// Rounding happens later.
//
return 0;
}
}
After¶
public class Report
{
public int Total()
{
// Sums the lines.
//
// Rounding happens later.
return 0;
}
}
Why¶
An empty comment is noise; inside a comment, an empty line separates paragraphs and stays.
How the fix works¶
Comments on consecutive lines form a group. Like StyleCop, empty // or /* */ comments are reported at the start and the end of a group; the fix removes every empty comment at that end, so one run is enough (StyleCop's fix removes one per run). When the removed lines sat between two blank lines, the blank lines below them go too, so no two blank lines are left in a row (BRO1517). A comment after code starts a new group, and //// (commented-out code) isn't empty.
Not reported¶
- Empty lines in the middle of a comment, which separate paragraphs.
- Empty comments that are all a pair of braces holds (
catch/{////}): they mark the block as empty on purpose, and removing them would leave a bare{ }. - The file header, when
file_header_templateis set: the comments the file starts with are the SDK's (IDE0073 writes them from the template, andCopyright ...puts an empty//line at the top and bottom of every header).
Compared with StyleCop¶
Same positions as StyleCop, except a file header with file_header_template set and empty comments a pair of braces holds (StyleCop reports both). StyleCop's fix removes only the reported comment, so a second empty one at the same end is reported on the next run.