Schenkerx has uploaded a new change for review.

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

Change subject: Fix trailing spaces and convert spaces to tabs
......................................................................

Fix trailing spaces and convert spaces to tabs

Bug: T129474
Change-Id: Ifd658c94552a3c9e33c2a1bd100f14cfcb8bf6ad
---
M MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
1 file changed, 53 insertions(+), 53 deletions(-)


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

diff --git a/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php 
b/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
index c2ff45c..9b7062d 100644
--- a/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
+++ b/MediaWiki/Sniffs/WhiteSpace/SpaceBeforeSingleLineCommentSniff.php
@@ -36,60 +36,60 @@
                                        $stackPtr,
                                        'EmptyComment'
                                );
-            // If the comment delimeter is "//"
+                       // If the comment delimeter is "//"
                        } elseif ( substr( $currToken['content'], 0, 2 ) === 
'//' ) {
-                $error = 'Single space expected between "//" and comment';
-                // No space between comment delimeter and the comment
-                if ( $currToken['content'][2] !== ' ' ) {
-                    $fix = $phpcsFile->addFixableWarning( $error, $stackPtr,
-                        'SingleSpaceBeforeSingleLineComment'
-                    );
-                    if ( $fix === true ) {
-                        $content = $currToken['content'];
-                        $newContent = substr_replace( $content, ' ', 2, 0 );
-                        $phpcsFile->fixer->replaceToken( $stackPtr, 
$newContent );
-                    }
-                // More than one spaces or tabs between comment delimeter 
-                // and the comment
-                } elseif ( preg_match( '/^\/\/((\s{2,})|(\t{1,}))/', 
-                        rtrim( $currToken['content'] ) )
-                ) {
-                    $fix = $phpcsFile->addFixableWarning( $error, $stackPtr,
-                        'SingleSpaceBeforeSingleLineComment'
-                    );
-                    if ( $fix === true ) {
-                        $content = $currToken['content'];
-                        $newContent = preg_replace( '/^\/\/\s+/', '// ', 
$content );
-                        $phpcsFile->fixer->replaceToken( $stackPtr, 
$newContent );
-                    }
-                }
-            // If the comment delimeter is "#"
-            } elseif ( $currToken['content'][0] === '#' ) {
-                $error = 'Single space expected between "#" and comment';
-                // No space between comment delimeter and the comment
-                if ( $currToken['content'][1] !== ' ' ) {
-                    $fix = $phpcsFile->addFixableWarning( $error, $stackPtr,
-                        'SingleSpaceBeforeSingleLineComment'
-                    );
-                    if ( $fix === true ) {
-                        $content = $currToken['content'];
-                        $newContent = substr_replace( $content, ' ', 1, 0 );
-                        $phpcsFile->fixer->replaceToken( $stackPtr, 
$newContent );
-                    }
-                // More than one spaces or tabs between comment delimeter 
-                // and the comment
-                } elseif ( preg_match( '/^#((\s{2,})|(\t{1,}))/', 
-                        rtrim( $currToken['content'] ) ) ) {
-                    $fix = $phpcsFile->addFixableWarning( $error, $stackPtr,
-                        'SingleSpaceBeforeSingleLineComment'
-                    );
-                    if ( $fix === true ) {
-                        $content = $currToken['content'];
-                        $newContent = preg_replace( '/^#\s+/', '# ', $content 
);
-                        $phpcsFile->fixer->replaceToken( $stackPtr, 
$newContent );
-                    }
-                }
-            }
+                               $error = 'Single space expected between "//" 
and comment';
+                               // No space between comment delimeter and the 
comment
+                               if ( $currToken['content'][2] !== ' ' ) {
+                                       $fix = $phpcsFile->addFixableWarning( 
$error, $stackPtr,
+                                               
'SingleSpaceBeforeSingleLineComment'
+                                       );
+                                       if ( $fix === true ) {
+                                               $content = 
$currToken['content'];
+                                               $newContent = substr_replace( 
$content, ' ', 2, 0 );
+                                               
$phpcsFile->fixer->replaceToken( $stackPtr, $newContent );
+                                       }
+                               // More than one spaces or tabs between comment 
delimeter
+                               // and the comment
+                               } elseif ( preg_match( 
'/^\/\/((\s{2,})|(\t{1,}))/',
+                                               rtrim( $currToken['content'] ) )
+                               ) {
+                                       $fix = $phpcsFile->addFixableWarning( 
$error, $stackPtr,
+                                               
'SingleSpaceBeforeSingleLineComment'
+                                       );
+                                       if ( $fix === true ) {
+                                               $content = 
$currToken['content'];
+                                               $newContent = preg_replace( 
'/^\/\/\s+/', '// ', $content );
+                                               
$phpcsFile->fixer->replaceToken( $stackPtr, $newContent );
+                                       }
+                               }
+                       // If the comment delimeter is "#"
+                       } elseif ( $currToken['content'][0] === '#' ) {
+                               $error = 'Single space expected between "#" and 
comment';
+                               // No space between comment delimeter and the 
comment
+                               if ( $currToken['content'][1] !== ' ' ) {
+                                       $fix = $phpcsFile->addFixableWarning( 
$error, $stackPtr,
+                                               
'SingleSpaceBeforeSingleLineComment'
+                                       );
+                                       if ( $fix === true ) {
+                                               $content = 
$currToken['content'];
+                                               $newContent = substr_replace( 
$content, ' ', 1, 0 );
+                                               
$phpcsFile->fixer->replaceToken( $stackPtr, $newContent );
+                                       }
+                               // More than one spaces or tabs between comment 
delimeter
+                               // and the comment
+                               } elseif ( preg_match( 
'/^#((\s{2,})|(\t{1,}))/',
+                                               rtrim( $currToken['content'] ) 
) ) {
+                                       $fix = $phpcsFile->addFixableWarning( 
$error, $stackPtr,
+                                               
'SingleSpaceBeforeSingleLineComment'
+                                       );
+                                       if ( $fix === true ) {
+                                               $content = 
$currToken['content'];
+                                               $newContent = preg_replace( 
'/^#\s+/', '# ', $content );
+                                               
$phpcsFile->fixer->replaceToken( $stackPtr, $newContent );
+                                       }
+                               }
+                       }
                }
        }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd658c94552a3c9e33c2a1bd100f14cfcb8bf6ad
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/tools/codesniffer
Gerrit-Branch: master
Gerrit-Owner: Schenkerx <[email protected]>

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

Reply via email to