Gergő Tisza has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/390178 )
Change subject: Remove WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment
......................................................................
Remove WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment
Empty comments are useful as paragraph breaks in multi-paragraph comments,
which improves readability of long comments. OTOH there isn't really any
unwanted behavior prevented by this rule that would be likely to occur
in the wild - it is easy get the spacing accidentaly, but accidentally
leaving empty comments is not likely to happen.
I've looked at only exempting empty comments when preceded and followed
by a comment, but PHP_CodeSniffer\Files\File is not really amenable to
line-based operations and it did not seem worth the effort.
Change-Id: I30e99d3e36fe3f18d56bc8fbae1b6e62471d81ea
---
M MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
M MediaWiki/Tests/files/WhiteSpace/space_before_singleline_comment.php.expect
2 files changed, 1 insertion(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/codesniffer
refs/changes/78/390178/1
diff --git a/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
b/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
index 68b1a49..647d624 100644
--- a/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
+++ b/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
@@ -54,10 +54,7 @@
( $currToken['content'][0] === '#' &&
rtrim( $currToken['content'] ) === '#' )
) {
- $phpcsFile->addWarning( 'Unnecessary empty
comment found',
- $stackPtr,
- 'EmptyComment'
- );
+ return;
// Checking whether there is a space between the
comment delimiter
// and the comment
} elseif ( substr( $currToken['content'], 0, 2 ) ===
'//' ) {
diff --git
a/MediaWiki/Tests/files/WhiteSpace/space_before_singleline_comment.php.expect
b/MediaWiki/Tests/files/WhiteSpace/space_before_singleline_comment.php.expect
index 53f88e7..b4d2e45 100644
---
a/MediaWiki/Tests/files/WhiteSpace/space_before_singleline_comment.php.expect
+++
b/MediaWiki/Tests/files/WhiteSpace/space_before_singleline_comment.php.expect
@@ -1,11 +1,7 @@
8 | WARNING | [x] Single space expected between "//" and comment
| |
(MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.SingleSpaceBeforeSingleLineComment)
- 9 | WARNING | [ ] Unnecessary empty comment found
- | |
(MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment)
10 | WARNING | [x] Single space expected between "#" and comment
| |
(MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.SingleSpaceBeforeSingleLineComment)
- 11 | WARNING | [ ] Unnecessary empty comment found
- | |
(MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment)
12 | WARNING | [x] Single space expected between "//" and comment
| |
(MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.SingleSpaceBeforeSingleLineComment)
13 | WARNING | [x] Single space expected between "#" and comment
--
To view, visit https://gerrit.wikimedia.org/r/390178
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I30e99d3e36fe3f18d56bc8fbae1b6e62471d81ea
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/codesniffer
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits