Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/250996

Change subject: Remove dead code from SpaceBeforeSingleLineCommentSniff
......................................................................

Remove dead code from SpaceBeforeSingleLineCommentSniff

This is dead code that does nothing. Here is why: The regular expression
matches any sequence of hash characters, even an empty sequence. But the
regex is not bound. It matches this anywhere inside the given string.
It searches for a pattern that can be empty. But every string contains an
empty pattern, no matter what the string actually contains. This means this
regex always succeeds and is never false.

I'm aware that this code had a purpose and was introduced in
https://gerrit.wikimedia.org/r/243619 for a reason. However, there was never
a test for this and I'm currently not aware of anybody complaining that this
particular feature was broken. So instead of fixing it I suggest to remove
it for now and re-add it later when somebody really asks for it.

Change-Id: I489874c67e404757f323e66c49f720e8a2d705ee
---
M MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
1 file changed, 0 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/codesniffer 
refs/changes/96/250996/1

diff --git a/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php 
b/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
index 0fc373f..2a42cff 100644
--- a/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
+++ b/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
@@ -24,9 +24,6 @@
                                || substr( $currToken['content'], 0, 3 ) === 
'///'
                        ) {
                                return;
-                       // Checking if it's a comment separator
-                       } elseif ( preg_match( '/#*/', $currToken['content'] ) 
=== false ) {
-                               return;
                        }
 
                        // Checking whether the comment is an empty one

-- 
To view, visit https://gerrit.wikimedia.org/r/250996
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I489874c67e404757f323e66c49f720e8a2d705ee
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/codesniffer
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to