Don't use `phpcs:ignoreFile` to selectively ignore sniffs
authorKunal Mehta <legoktm@member.fsf.org>
Sun, 8 Apr 2018 19:39:46 +0000 (12:39 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Mon, 9 Apr 2018 00:08:53 +0000 (17:08 -0700)
Because it doesn't work. `phpcs:ignoreFile` is intended as a performance
shortcut, and gives up on the file as soon as that token is found.
Instead, use `phpcs:disable` which does support selectively disabling
some sniffs. And since disabling is local to the file, there's no need
to re-enable it at the bottom of the file.

<https://github.com/squizlabs/PHP_CodeSniffer/issues/1903> has some
relevant discussion and clarification from upstream on this.

And make the files that are now being re-enabled pass PHPCS.

Change-Id: Ia4d8c45045f61cf9f24eb1d8631ff98d99c82d69

autoload.php
includes/PHPVersionCheck.php
includes/utils/AutoloadGenerator.php
mw-config/index.php

index b4596c4..4076620 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // This file is generated by maintenance/generateLocalAutoload.php, do not adjust manually
 <?php
 // This file is generated by maintenance/generateLocalAutoload.php, do not adjust manually
-// phpcs:ignoreFile Generic.Files.LineLength
+// phpcs:disable Generic.Files.LineLength
 global $wgAutoloadLocalClasses;
 
 $wgAutoloadLocalClasses = [
 global $wgAutoloadLocalClasses;
 
 $wgAutoloadLocalClasses = [
index a48d460..77c725f 100644 (file)
@@ -1,5 +1,4 @@
 <?php
 <?php
-// phpcs:ignoreFile Generic.Arrays.DisallowLongArraySyntax,MediaWiki.Usage.DirUsage.FunctionFound
 /**
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 /**
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,6 +18,7 @@
  * @file
  */
 
  * @file
  */
 
+// phpcs:disable Generic.Arrays.DisallowLongArraySyntax,PSR2.Classes.PropertyDeclaration,MediaWiki.Usage.DirUsage
 /**
  * Check PHP Version, as well as for composer dependencies in entry points,
  * and display something vaguely comprehensible in the event of a totally
 /**
  * Check PHP Version, as well as for composer dependencies in entry points,
  * and display something vaguely comprehensible in the event of a totally
@@ -124,7 +124,7 @@ class PHPVersionCheck {
                                . "{$otherInfo['minSupported']}.\n\nCheck if you have a"
                                . " newer php executable with a different name, such as php5.\n\n";
 
                                . "{$otherInfo['minSupported']}.\n\nCheck if you have a"
                                . " newer php executable with a different name, such as php5.\n\n";
 
-                       // phpcs:ignore Generic.Files.LineLength
+                       // phpcs:disable Generic.Files.LineLength
                        $longHtml = <<<HTML
                        Please consider <a href="{$phpInfo['upgradeURL']}">upgrading your copy of
                        {$phpInfo['implementation']}</a>.
                        $longHtml = <<<HTML
                        Please consider <a href="{$phpInfo['upgradeURL']}">upgrading your copy of
                        {$phpInfo['implementation']}</a>.
@@ -139,7 +139,7 @@ class PHPVersionCheck {
                        See our<a href="https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
                        for details of which versions are compatible with prior versions of {$phpInfo['implementation']}.
 HTML;
                        See our<a href="https://www.mediawiki.org/wiki/Compatibility#PHP">compatibility page</a>
                        for details of which versions are compatible with prior versions of {$phpInfo['implementation']}.
 HTML;
-                       // phpcs:enable
+                       // phpcs:enable Generic.Files.LineLength
                        $this->triggerError(
                                "Supported {$phpInfo['implementation']} versions",
                                $shortText,
                        $this->triggerError(
                                "Supported {$phpInfo['implementation']} versions",
                                $shortText,
@@ -164,14 +164,14 @@ HTML;
                                . "https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
                                . "for help on installing the required components.";
 
                                . "https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries\n"
                                . "for help on installing the required components.";
 
-                       // phpcs:ignore Generic.Files.LineLength
+                       // phpcs:disable Generic.Files.LineLength
                        $longHtml = <<<HTML
                MediaWiki now also has some external dependencies that need to be installed via
                composer or from a separate git repo. Please see
                <a href="https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">mediawiki.org</a>
                for help on installing the required components.
 HTML;
                        $longHtml = <<<HTML
                MediaWiki now also has some external dependencies that need to be installed via
                composer or from a separate git repo. Please see
                <a href="https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">mediawiki.org</a>
                for help on installing the required components.
 HTML;
-                       // phpcs:enable
+                       // phpcs:enable Generic.Files.LineLength
 
                        $this->triggerError( 'External dependencies', $shortText, $longText, $longHtml );
                }
 
                        $this->triggerError( 'External dependencies', $shortText, $longText, $longHtml );
                }
index a6783b0..0e2ef85 100644 (file)
@@ -239,7 +239,7 @@ class AutoloadGenerator {
                return <<<EOD
 <?php
 // This file is generated by $commandName, do not adjust manually
                return <<<EOD
 <?php
 // This file is generated by $commandName, do not adjust manually
-// phpcs:ignoreFile Generic.Files.LineLength
+// phpcs:disable Generic.Files.LineLength
 global \${$this->variableName};
 
 \${$this->variableName} {$op} [
 global \${$this->variableName};
 
 \${$this->variableName} {$op} [
index 72cf654..a47822b 100644 (file)
@@ -1,5 +1,5 @@
 <?php
 <?php
-// phpcs:ignoreFile Generic.Arrays.DisallowLongArraySyntax
+// phpcs:disable Generic.Arrays.DisallowLongArraySyntax
 /**
  * New version of MediaWiki web-based config/installation
  *
 /**
  * New version of MediaWiki web-based config/installation
  *
@@ -79,5 +79,4 @@ function wfInstallerMain() {
        $session = $installer->execute( $session );
 
        $_SESSION['installData'][$fingerprint] = $session;
        $session = $installer->execute( $session );
 
        $_SESSION['installData'][$fingerprint] = $session;
-
 }
 }