Make WordPress Core

Changeset 56593


Ignore:
Timestamp:
09/15/2023 09:06:23 AM (15 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Improve organization of the WPCS-based PHPCS ruleset.

This commit:

  • Adds section headers to the ruleset file.
  • Organizes all directives in their respective sections.

No functional changes.

Props jrf.
See #59161.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpcs.xml.dist

    r56500 r56593  
    33    <description>Apply WordPress Coding Standards to all Core files</description>
    44
     5    <!--
     6    #############################################################################
     7    COMMAND LINE ARGUMENTS
     8    https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset
     9    #############################################################################
     10    -->
     11
    512    <!-- Only scan PHP files. -->
    613    <arg name="extensions" value="php"/>
     
    2431    <arg value="ps"/>
    2532
     33    <!--
     34    #############################################################################
     35    FILE SELECTION
     36    Set which files will be subject to the scans executed using this ruleset.
     37    #############################################################################
     38    -->
     39
    2640    <file>.</file>
     41
     42    <!-- Exclude the build folder in the current directory. -->
     43    <exclude-pattern type="relative">^build/*</exclude-pattern>
     44
     45    <!-- Directories and third party library exclusions. -->
     46    <exclude-pattern>/node_modules/*</exclude-pattern>
     47    <exclude-pattern>/vendor/*</exclude-pattern>
     48
     49    <exclude-pattern>/src/wp-admin/includes/class-ftp*</exclude-pattern>
     50    <exclude-pattern>/src/wp-admin/includes/class-pclzip\.php</exclude-pattern>
     51    <exclude-pattern>/src/wp-admin/includes/deprecated\.php</exclude-pattern>
     52    <exclude-pattern>/src/wp-admin/includes/ms-deprecated\.php</exclude-pattern>
     53
     54    <exclude-pattern>/src/wp-includes/atomlib\.php</exclude-pattern>
     55    <exclude-pattern>/src/wp-includes/class-IXR\.php</exclude-pattern>
     56    <exclude-pattern>/src/wp-includes/class-json\.php</exclude-pattern>
     57    <exclude-pattern>/src/wp-includes/class-phpass\.php</exclude-pattern>
     58    <exclude-pattern>/src/wp-includes/class-pop3\.php</exclude-pattern>
     59    <exclude-pattern>/src/wp-includes/class-requests\.php</exclude-pattern>
     60    <exclude-pattern>/src/wp-includes/class-simplepie\.php</exclude-pattern>
     61    <exclude-pattern>/src/wp-includes/class-snoopy\.php</exclude-pattern>
     62    <exclude-pattern>/src/wp-includes/deprecated\.php</exclude-pattern>
     63    <exclude-pattern>/src/wp-includes/ms-deprecated\.php</exclude-pattern>
     64    <exclude-pattern>/src/wp-includes/pluggable-deprecated\.php</exclude-pattern>
     65    <exclude-pattern>/src/wp-includes/rss\.php</exclude-pattern>
     66
     67    <exclude-pattern>/src/wp-includes/assets/*</exclude-pattern>
     68    <exclude-pattern>/src/wp-includes/blocks/*/*.asset.php</exclude-pattern>
     69    <exclude-pattern>/src/wp-includes/blocks/blocks-json.php</exclude-pattern>
     70    <exclude-pattern>/src/wp-includes/ID3/*</exclude-pattern>
     71    <exclude-pattern>/src/wp-includes/IXR/*</exclude-pattern>
     72    <exclude-pattern>/src/wp-includes/js/*</exclude-pattern>
     73    <exclude-pattern>/src/wp-includes/PHPMailer/*</exclude-pattern>
     74    <exclude-pattern>/src/wp-includes/random_compat/*</exclude-pattern>
     75    <exclude-pattern>/src/wp-includes/Requests/*</exclude-pattern>
     76    <exclude-pattern>/src/wp-includes/SimplePie/*</exclude-pattern>
     77    <exclude-pattern>/src/wp-includes/sodium_compat/*</exclude-pattern>
     78    <exclude-pattern>/src/wp-includes/Text/*</exclude-pattern>
     79
     80    <!-- Test data and fixtures. -->
     81    <exclude-pattern>/tests/phpunit/build*</exclude-pattern>
     82    <exclude-pattern>/tests/phpunit/data/*</exclude-pattern>
     83
     84    <exclude-pattern>/tools/*</exclude-pattern>
     85
     86    <!-- Drop-in plugins. -->
     87    <exclude-pattern>/src/wp-content/advanced-cache\.php</exclude-pattern>
     88    <exclude-pattern>/src/wp-content/blog-deleted\.php</exclude-pattern>
     89    <exclude-pattern>/src/wp-content/blog-inactive\.php</exclude-pattern>
     90    <exclude-pattern>/src/wp-content/blog-suspended\.php</exclude-pattern>
     91    <exclude-pattern>/src/wp-content/db-error\.php</exclude-pattern>
     92    <exclude-pattern>/src/wp-content/db\.php</exclude-pattern>
     93    <exclude-pattern>/src/wp-content/fatal-error-handler\.php</exclude-pattern>
     94    <exclude-pattern>/src/wp-content/install\.php</exclude-pattern>
     95    <exclude-pattern>/src/wp-content/maintenance\.php</exclude-pattern>
     96    <exclude-pattern>/src/wp-content/object-cache\.php</exclude-pattern>
     97    <exclude-pattern>/src/wp-content/php-error\.php</exclude-pattern>
     98    <exclude-pattern>/src/wp-content/sunrise\.php</exclude-pattern>
     99
     100    <!-- Must-Use plugins. -->
     101    <exclude-pattern>/src/wp-content/mu-plugins/*</exclude-pattern>
     102
     103    <!-- Plugins. -->
     104    <exclude-pattern>/src/wp-content/plugins/*</exclude-pattern>
     105
     106    <!-- Themes except the twenty* themes. -->
     107    <exclude-pattern>/src/wp-content/themes/(?!twenty)*</exclude-pattern>
     108
     109
     110    <!--
     111    #############################################################################
     112    SET UP THE RULESET
     113    #############################################################################
     114    -->
    27115
    28116    <rule ref="WordPress-Core"/>
    29117    <rule ref="WordPress.CodeAnalysis.EmptyStatement"/>
    30118
     119    <!-- Enforce no parenthesis for language constructs, and only one space immediately after.
     120         Including this rule is temporary until it is moved from the WordPress-Extra ruleset to
     121         the WordPress-Core ruleset upstream.
     122    -->
     123    <rule ref="PEAR.Files.IncludingFile.BracketsNotRequired">
     124        <type>warning</type>
     125    </rule>
     126    <rule ref="PEAR.Files.IncludingFile.UseRequire">
     127        <type>warning</type>
     128    </rule>
     129    <rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
     130        <type>warning</type>
     131    </rule>
     132    <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
     133
     134
     135    <!--
     136    #############################################################################
     137    SNIFF-SPECIFIC CONFIGURATION
     138    #############################################################################
     139    -->
     140
    31141    <!-- These rules are being set as warnings instead of errors, so we can error check the entire codebase. -->
     142    <rule ref="WordPress.DB.PreparedSQL.InterpolatedNotPrepared">
     143        <type>warning</type>
     144    </rule>
     145    <rule ref="WordPress.DB.PreparedSQL.NotPrepared">
     146        <type>warning</type>
     147    </rule>
     148    <rule ref="WordPress.Files.FileName.InvalidClassFileName">
     149        <type>warning</type>
     150    </rule>
    32151    <rule ref="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase">
    33152        <type>warning</type>
    34153    </rule>
    35     <rule ref="WordPress.DB.PreparedSQL.InterpolatedNotPrepared">
    36         <type>warning</type>
    37     </rule>
    38     <rule ref="WordPress.DB.PreparedSQL.NotPrepared">
    39         <type>warning</type>
    40     </rule>
    41     <rule ref="WordPress.Files.FileName.InvalidClassFileName">
    42         <type>warning</type>
     154
     155    <!-- Allow test classes for select sniffs. -->
     156    <rule ref="WordPress.Files.FileName">
     157        <properties>
     158            <property name="custom_test_class_whitelist" type="array">
     159                <!-- Test case parent classes in the "includes" folder, not yet accounted for in WPCS. -->
     160                <element value="PHPUnit_Adapter_TestCase"/>
     161                <element value="WP_Test_XML_TestCase"/>
     162
     163                <!-- Test case parent classes outside of the "includes" folder. -->
     164                <element value="Tests_Query_Conditionals"/>
     165                <element value="WP_Block_Templates_UnitTestCase"/>
     166                <element value="WP_Filesystem_UnitTestCase"/>
     167                <element value="WP_HTTP_UnitTestCase"/>
     168                <element value="WP_Image_UnitTestCase"/>
     169                <element value="WP_Import_UnitTestCase"/>
     170                <element value="WP_Test_Adjacent_Image_Link_TestCase"/>
     171                <element value="WP_Tests_Image_Resize_UnitTestCase"/>
     172                <element value="WP_Theme_UnitTestCase"/>
     173                <element value="WP_Font_Face_UnitTestCase"/>
     174
     175                <!-- Mock classes. -->
     176                <element value="Spy_REST_Server"/>
     177                <element value="WP_REST_Test_Controller"/>
     178                <element value="WP_Image_Editor_Mock"/>
     179                <element value="WP_Filesystem_MockFS"/>
     180                <element value="Mock_Invokable"/>
     181                <element value="MockPHPMailer"/>
     182                <element value="MockAction"/>
     183                <element value="WP_Object_Cache"/>
     184
     185                <!-- PHPUnit helpers. -->
     186                <element value="TracTickets"/>
     187                <element value="WP_PHPUnit_Util_Getopt"/>
     188                <element value="PHPUnit_Util_Test"/>
     189                <element value="WPProfiler"/>
     190                <element value="PHPUnit_Framework_Exception"/>
     191                <element value="Polyfill_TestCase"/>
     192            </property>
     193        </properties>
    43194    </rule>
    44195
     
    99250    </rule>
    100251
    101     <!-- Exclude the build folder in the current directory. -->
    102     <exclude-pattern type="relative">^build/*</exclude-pattern>
    103 
    104     <!-- Directories and third party library exclusions. -->
    105     <exclude-pattern>/node_modules/*</exclude-pattern>
    106     <exclude-pattern>/vendor/*</exclude-pattern>
    107 
    108     <exclude-pattern>/src/wp-admin/includes/class-ftp*</exclude-pattern>
    109     <exclude-pattern>/src/wp-admin/includes/class-pclzip\.php</exclude-pattern>
    110     <exclude-pattern>/src/wp-admin/includes/deprecated\.php</exclude-pattern>
    111     <exclude-pattern>/src/wp-admin/includes/ms-deprecated\.php</exclude-pattern>
    112 
    113     <exclude-pattern>/src/wp-includes/atomlib\.php</exclude-pattern>
    114     <exclude-pattern>/src/wp-includes/class-IXR\.php</exclude-pattern>
    115     <exclude-pattern>/src/wp-includes/class-json\.php</exclude-pattern>
    116     <exclude-pattern>/src/wp-includes/class-phpass\.php</exclude-pattern>
    117     <exclude-pattern>/src/wp-includes/class-pop3\.php</exclude-pattern>
    118     <exclude-pattern>/src/wp-includes/class-requests\.php</exclude-pattern>
    119     <exclude-pattern>/src/wp-includes/class-simplepie\.php</exclude-pattern>
    120     <exclude-pattern>/src/wp-includes/class-snoopy\.php</exclude-pattern>
    121     <exclude-pattern>/src/wp-includes/deprecated\.php</exclude-pattern>
    122     <exclude-pattern>/src/wp-includes/ms-deprecated\.php</exclude-pattern>
    123     <exclude-pattern>/src/wp-includes/pluggable-deprecated\.php</exclude-pattern>
    124     <exclude-pattern>/src/wp-includes/rss\.php</exclude-pattern>
    125 
    126     <exclude-pattern>/src/wp-includes/assets/*</exclude-pattern>
    127     <exclude-pattern>/src/wp-includes/blocks/*/*.asset.php</exclude-pattern>
    128     <exclude-pattern>/src/wp-includes/blocks/blocks-json.php</exclude-pattern>
    129     <exclude-pattern>/src/wp-includes/ID3/*</exclude-pattern>
    130     <exclude-pattern>/src/wp-includes/IXR/*</exclude-pattern>
    131     <exclude-pattern>/src/wp-includes/js/*</exclude-pattern>
    132     <exclude-pattern>/src/wp-includes/PHPMailer/*</exclude-pattern>
    133     <exclude-pattern>/src/wp-includes/random_compat/*</exclude-pattern>
    134     <exclude-pattern>/src/wp-includes/Requests/*</exclude-pattern>
    135     <exclude-pattern>/src/wp-includes/SimplePie/*</exclude-pattern>
    136     <exclude-pattern>/src/wp-includes/sodium_compat/*</exclude-pattern>
    137     <exclude-pattern>/src/wp-includes/Text/*</exclude-pattern>
    138 
    139     <!-- Test data and fixtures. -->
    140     <exclude-pattern>/tests/phpunit/build*</exclude-pattern>
    141     <exclude-pattern>/tests/phpunit/data/*</exclude-pattern>
    142 
    143     <exclude-pattern>/tools/*</exclude-pattern>
    144 
    145     <!-- Drop-in plugins. -->
    146     <exclude-pattern>/src/wp-content/advanced-cache\.php</exclude-pattern>
    147     <exclude-pattern>/src/wp-content/blog-deleted\.php</exclude-pattern>
    148     <exclude-pattern>/src/wp-content/blog-inactive\.php</exclude-pattern>
    149     <exclude-pattern>/src/wp-content/blog-suspended\.php</exclude-pattern>
    150     <exclude-pattern>/src/wp-content/db-error\.php</exclude-pattern>
    151     <exclude-pattern>/src/wp-content/db\.php</exclude-pattern>
    152     <exclude-pattern>/src/wp-content/fatal-error-handler\.php</exclude-pattern>
    153     <exclude-pattern>/src/wp-content/install\.php</exclude-pattern>
    154     <exclude-pattern>/src/wp-content/maintenance\.php</exclude-pattern>
    155     <exclude-pattern>/src/wp-content/object-cache\.php</exclude-pattern>
    156     <exclude-pattern>/src/wp-content/php-error\.php</exclude-pattern>
    157     <exclude-pattern>/src/wp-content/sunrise\.php</exclude-pattern>
    158 
    159     <!-- Must-Use plugins. -->
    160     <exclude-pattern>/src/wp-content/mu-plugins/*</exclude-pattern>
    161 
    162     <!-- Plugins. -->
    163     <exclude-pattern>/src/wp-content/plugins/*</exclude-pattern>
    164 
    165     <!-- Themes except the twenty* themes. -->
    166     <exclude-pattern>/src/wp-content/themes/(?!twenty)*</exclude-pattern>
    167 
    168     <!-- Allow the WP DB Class and related tests for usage of direct database access functions. -->
    169     <rule ref="WordPress.DB.RestrictedFunctions">
    170         <exclude-pattern>/src/wp-includes/class-wpdb\.php</exclude-pattern>
    171         <exclude-pattern>/tests/phpunit/tests/db/charset\.php</exclude-pattern>
    172     </rule>
    173 
    174     <!-- Allow the WP DB related tests for issues with prepared SQL placeholders
    175          (as the handling of those are being tested). -->
    176     <rule ref="WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare">
    177         <exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
    178     </rule>
    179     <rule ref="WordPress.DB.PreparedSQLPlaceholders.UnsupportedPlaceholder">
    180         <exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
    181     </rule>
    182     <rule ref="WordPress.DB.PreparedSQLPlaceholders.UnescapedLiteral">
    183         <exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
    184     </rule>
    185     <rule ref="WordPress.DB.PreparedSQL.NotPrepared">
    186         <exclude-pattern>/tests/phpunit/tests/admin/includesSchema\.php</exclude-pattern>
    187         <exclude-pattern>/tests/phpunit/tests/multisite/site\.php</exclude-pattern>
    188     </rule>
    189 
    190     <!-- Allow non-snake-case vars & properties for block-related classes. -->
    191     <rule ref="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase">
    192         <exclude-pattern>/src/wp-includes/class-wp-block-parser\.php</exclude-pattern>
    193         <exclude-pattern>/src/wp-includes/class-wp-block-parser-block\.php</exclude-pattern>
    194     </rule>
    195     <rule ref="WordPress.NamingConventions.ValidVariableName.PropertyNotSnakeCase">
    196         <exclude-pattern>/src/wp-includes/class-wp-block-parser-block\.php</exclude-pattern>
    197     </rule>
    198     <rule ref="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase">
    199         <exclude-pattern>/src/wp-includes/class-wp-block-parser-block\.php</exclude-pattern>
    200     </rule>
    201 
    202     <!-- Allow the I18n functions file for issues identified by the I18n sniff
    203          (such as calling the low-level translate() function). -->
    204     <rule ref="WordPress.WP.I18n">
    205         <exclude-pattern>/src/wp-includes/l10n\.php</exclude-pattern>
    206         <exclude-pattern>/tests/phpunit/tests/l10n\.php</exclude-pattern>
    207         <exclude-pattern>/tests/phpunit/tests/l10n/loadTextdomainJustInTime\.php</exclude-pattern>
    208     </rule>
    209 
    210     <!-- Translator comments aren't needed in unit tests. -->
    211     <rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
    212         <exclude-pattern>/tests/*</exclude-pattern>
    213     </rule>
    214 
    215     <rule ref="Generic.Functions.FunctionCallArgumentSpacing">
    216         <exclude-pattern>/wp-config\.php</exclude-pattern>
    217         <exclude-pattern>/wp-config-sample\.php</exclude-pattern>
    218         <exclude-pattern>/wp-tests-config\.php</exclude-pattern>
    219         <exclude-pattern>/wp-tests-config-sample\.php</exclude-pattern>
    220     </rule>
    221 
    222     <!-- Exclude checking of line endings when reporting errors, but fix them when running phpcbf.
    223          Git and SVN manage these pretty well cross-platform as "native".
    224          Allow configuration files. -->
    225     <rule ref="Generic.Files.LineEndings">
    226         <exclude-pattern>/wp-config\.php</exclude-pattern>
    227         <exclude-pattern>/wp-config-sample\.php</exclude-pattern>
    228         <exclude phpcs-only="true" name="Generic.Files.LineEndings"/>
    229     </rule>
    230 
    231     <!-- WPCS1620: template.php isn't a template tag file. -->
    232     <rule ref="WordPress.Files.FileName.InvalidTemplateTagFileName">
    233         <exclude-pattern>/src/wp-includes/template\.php</exclude-pattern>
    234     </rule>
    235 
    236     <!-- WPCS1621: These files are expected to use _ instead of -. -->
    237     <rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
    238         <exclude-pattern>/src/_index\.php</exclude-pattern>
    239         <exclude-pattern>/src/wp-admin/_index\.php</exclude-pattern>
    240         <exclude-pattern>/src/wp-content/themes/twentythirteen/taxonomy-post_format\.php</exclude-pattern>
    241         <exclude-pattern>/src/wp-content/themes/twentyfourteen/taxonomy-post_format\.php</exclude-pattern>
    242     </rule>
    243 
    244     <!-- Allow test classes for select sniffs. -->
    245     <rule ref="WordPress.Files.FileName">
    246         <properties>
    247             <property name="custom_test_class_whitelist" type="array">
    248                 <!-- Test case parent classes in the "includes" folder, not yet accounted for in WPCS. -->
    249                 <element value="PHPUnit_Adapter_TestCase"/>
    250                 <element value="WP_Test_XML_TestCase"/>
    251 
    252                 <!-- Test case parent classes outside of the "includes" folder. -->
    253                 <element value="Tests_Query_Conditionals"/>
    254                 <element value="WP_Block_Templates_UnitTestCase"/>
    255                 <element value="WP_Filesystem_UnitTestCase"/>
    256                 <element value="WP_HTTP_UnitTestCase"/>
    257                 <element value="WP_Image_UnitTestCase"/>
    258                 <element value="WP_Import_UnitTestCase"/>
    259                 <element value="WP_Test_Adjacent_Image_Link_TestCase"/>
    260                 <element value="WP_Tests_Image_Resize_UnitTestCase"/>
    261                 <element value="WP_Theme_UnitTestCase"/>
    262                 <element value="WP_Font_Face_UnitTestCase"/>
    263 
    264                 <!-- Mock classes. -->
    265                 <element value="Spy_REST_Server"/>
    266                 <element value="WP_REST_Test_Controller"/>
    267                 <element value="WP_Image_Editor_Mock"/>
    268                 <element value="WP_Filesystem_MockFS"/>
    269                 <element value="Mock_Invokable"/>
    270                 <element value="MockPHPMailer"/>
    271                 <element value="MockAction"/>
    272                 <element value="WP_Object_Cache"/>
    273 
    274                 <!-- PHPUnit helpers. -->
    275                 <element value="TracTickets"/>
    276                 <element value="WP_PHPUnit_Util_Getopt"/>
    277                 <element value="PHPUnit_Util_Test"/>
    278                 <element value="WPProfiler"/>
    279                 <element value="PHPUnit_Framework_Exception"/>
    280                 <element value="Polyfill_TestCase"/>
    281             </property>
    282         </properties>
    283     </rule>
    284 
    285252    <rule ref="WordPress.PHP.NoSilencedErrors">
    286253        <properties>
     
    305272    </rule>
    306273
    307     <!-- Enforce no parenthesis for language constructs, and only one space immediately after.
    308          Including this rule is temporary until it is moved from the WordPress-Extra ruleset to
    309          the WordPress-Core ruleset upstream.
    310     -->
    311     <rule ref="PEAR.Files.IncludingFile.BracketsNotRequired">
    312         <type>warning</type>
    313     </rule>
    314     <rule ref="PEAR.Files.IncludingFile.UseRequire">
    315         <type>warning</type>
    316     </rule>
    317     <rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
    318         <type>warning</type>
    319     </rule>
    320     <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
    321 
    322     <!-- Assignments in while conditions are a valid method of looping over iterables. -->
    323     <rule ref="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition">
    324         <exclude-pattern>*</exclude-pattern>
    325     </rule>
    326 
    327     <!-- Exclude the unit tests from select sniffs. -->
    328     <rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
    329         <exclude-pattern>/tests/phpunit/tests/*</exclude-pattern>
    330     </rule>
     274
     275    <!--
     276    #############################################################################
     277    SELECTIVE EXCLUSIONS
     278    Exclude specific files for specific sniffs and/or exclude sub-groups in sniffs.
     279   
     280    These exclusions are listed ordered by alphabetic sniff name.
     281    #############################################################################
     282    -->
     283
     284    <!-- Exclude checking of line endings when reporting errors, but fix them when running phpcbf.
     285         Git and SVN manage these pretty well cross-platform as "native".
     286         Allow configuration files. -->
     287    <rule ref="Generic.Files.LineEndings">
     288        <exclude-pattern>/wp-config\.php</exclude-pattern>
     289        <exclude-pattern>/wp-config-sample\.php</exclude-pattern>
     290        <exclude phpcs-only="true" name="Generic.Files.LineEndings"/>
     291    </rule>
     292
     293    <rule ref="Generic.Functions.FunctionCallArgumentSpacing">
     294        <exclude-pattern>/wp-config\.php</exclude-pattern>
     295        <exclude-pattern>/wp-config-sample\.php</exclude-pattern>
     296        <exclude-pattern>/wp-tests-config\.php</exclude-pattern>
     297        <exclude-pattern>/wp-tests-config-sample\.php</exclude-pattern>
     298    </rule>
     299
    331300    <rule ref="PEAR.NamingConventions.ValidClassName.Invalid">
    332301        <exclude-pattern>/tests/phpunit/tests/*</exclude-pattern>
    333     </rule>
    334 
    335     <!-- Exclude some old classes that cannot be renamed, as it would break back compat. -->
    336     <rule ref="PEAR.NamingConventions.ValidClassName.Invalid">
     302        <!-- Exclude some old classes that cannot be renamed, as it would break back compat. -->
    337303        <exclude-pattern>/src/wp-admin/includes/class-wp-filesystem-ftpsockets\.php</exclude-pattern>
    338304        <exclude-pattern>/src/wp-includes/class-wp-oembed\.php</exclude-pattern>
     
    341307        <exclude-pattern>/src/wp-includes/class-wp-text-diff-renderer-inline\.php</exclude-pattern>
    342308    </rule>
     309
     310    <!-- Exclude some old classes that cannot be renamed, as it would break back compat. -->
    343311    <rule ref="PEAR.NamingConventions.ValidClassName.StartWithCapital">
    344312        <exclude-pattern>/src/wp-admin/includes/class-wp-list-table-compat\.php</exclude-pattern>
     
    347315        <exclude-pattern>/src/wp-includes/class-wp-xmlrpc-server\.php</exclude-pattern>
    348316        <exclude-pattern>/src/wp-includes/class-wpdb\.php</exclude-pattern>
     317    </rule>
     318
     319    <!-- Assignments in while conditions are a valid method of looping over iterables. -->
     320    <rule ref="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition">
     321        <exclude-pattern>*</exclude-pattern>
     322    </rule>
     323
     324    <!-- Allow the WP DB Class and related tests for usage of direct database access functions. -->
     325    <rule ref="WordPress.DB.RestrictedFunctions">
     326        <exclude-pattern>/src/wp-includes/class-wpdb\.php</exclude-pattern>
     327        <exclude-pattern>/tests/phpunit/tests/db/charset\.php</exclude-pattern>
     328    </rule>
     329
     330    <!-- Allow the WP DB related tests for issues with prepared SQL placeholders
     331         (as the handling of those are being tested). -->
     332    <rule ref="WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare">
     333        <exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
     334    </rule>
     335    <rule ref="WordPress.DB.PreparedSQLPlaceholders.UnsupportedPlaceholder">
     336        <exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
     337    </rule>
     338    <rule ref="WordPress.DB.PreparedSQLPlaceholders.UnescapedLiteral">
     339        <exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
     340    </rule>
     341    <rule ref="WordPress.DB.PreparedSQL.NotPrepared">
     342        <exclude-pattern>/tests/phpunit/tests/admin/includesSchema\.php</exclude-pattern>
     343        <exclude-pattern>/tests/phpunit/tests/multisite/site\.php</exclude-pattern>
     344    </rule>
     345
     346    <!-- WPCS1620: template.php isn't a template tag file. -->
     347    <rule ref="WordPress.Files.FileName.InvalidTemplateTagFileName">
     348        <exclude-pattern>/src/wp-includes/template\.php</exclude-pattern>
     349    </rule>
     350
     351    <!-- Exclude the unit tests from select sniffs. -->
     352    <rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
     353        <exclude-pattern>/tests/phpunit/tests/*</exclude-pattern>
    349354    </rule>
    350355
     
    358363        <exclude-pattern>/src/wp-content/themes/twentyfourteen/inc/featured-content\.php</exclude-pattern>
    359364    </rule>
     365
     366    <!-- WPCS1621: These files are expected to use _ instead of -. -->
     367    <rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
     368        <exclude-pattern>/src/_index\.php</exclude-pattern>
     369        <exclude-pattern>/src/wp-admin/_index\.php</exclude-pattern>
     370        <exclude-pattern>/src/wp-content/themes/twentythirteen/taxonomy-post_format\.php</exclude-pattern>
     371        <exclude-pattern>/src/wp-content/themes/twentyfourteen/taxonomy-post_format\.php</exclude-pattern>
     372    </rule>
     373
     374    <!-- Allow the I18n functions file for issues identified by the I18n sniff
     375         (such as calling the low-level translate() function). -->
     376    <rule ref="WordPress.WP.I18n">
     377        <exclude-pattern>/src/wp-includes/l10n\.php</exclude-pattern>
     378        <exclude-pattern>/tests/phpunit/tests/l10n\.php</exclude-pattern>
     379        <exclude-pattern>/tests/phpunit/tests/l10n/loadTextdomainJustInTime\.php</exclude-pattern>
     380    </rule>
     381
     382    <!-- Translator comments aren't needed in unit tests. -->
     383    <rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
     384        <exclude-pattern>/tests/*</exclude-pattern>
     385    </rule>
     386
     387    <!-- Allow non-snake-case vars & properties for block-related classes. -->
     388    <rule ref="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase">
     389        <exclude-pattern>/src/wp-includes/class-wp-block-parser\.php</exclude-pattern>
     390        <exclude-pattern>/src/wp-includes/class-wp-block-parser-block\.php</exclude-pattern>
     391    </rule>
     392    <rule ref="WordPress.NamingConventions.ValidVariableName.PropertyNotSnakeCase">
     393        <exclude-pattern>/src/wp-includes/class-wp-block-parser-block\.php</exclude-pattern>
     394    </rule>
     395    <rule ref="WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase">
     396        <exclude-pattern>/src/wp-includes/class-wp-block-parser-block\.php</exclude-pattern>
     397    </rule>
     398
    360399</ruleset>
Note: See TracChangeset for help on using the changeset viewer.