Skip to:
Content

bbPress.org

Changeset 7050


Ignore:
Timestamp:
12/15/2019 11:52:57 AM (2 months ago)
Author:
netweb
Message:

Build Tools: Improve PHPCS setup.

Props jrf.
See #3294.
For trunk.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpcs.xml.dist

    r7042 r7050  
    11<?xml version="1.0"?>
    2 <ruleset name="WordPress Coding Standards">
    3     <description>Apply WordPress Coding Standards to all Core files with scpecific bbPress exclusions</description>
    4 
    5     <rule ref="WordPress-Core"/>
    6 
    7     <arg name="extensions" value="php"/>
    8 
    9     <!-- Strip the filepaths down to the relevant bit. -->
    10     <arg name="basepath" value="./"/>
    11 
    12     <!-- Check up to 20 files simultaneously. -->
    13     <arg name="parallel" value="20"/>
    14 
    15     <!-- Show sniff codes in all reports -->
    16     <arg value="psv"/>
     2<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     3    name="bbPress"
     4    xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
     5
     6    <description>Apply WordPress Coding Standards to all Core files with specific bbPress exclusions</description>
     7
     8    <!--
     9    #############################################################################
     10    COMMAND LINE ARGUMENTS
     11    https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
     12    #############################################################################
     13    -->
    1714
    1815    <file>.</file>
     
    3128
    3229    <!-- Exclude the NBBC parser. See https://github.com/bbpress/nbbc -->
    33     <exclude-pattern>/src/includes/admin/parser.php</exclude-pattern>
     30    <exclude-pattern>/src/includes/admin/parser\.php$</exclude-pattern>
     31
     32    <arg name="extensions" value="php"/>
     33
     34    <!-- Strip the filepaths down to the relevant bit. -->
     35    <arg name="basepath" value="./"/>
     36
     37    <!-- Check up to 20 files simultaneously. -->
     38    <arg name="parallel" value="20"/>
     39
     40    <!-- Show progress, show the error codes for each message (source). -->
     41    <arg value="ps"/>
     42
     43
     44    <!--
     45    #############################################################################
     46    SET UP THE RULES TO USE
     47    #############################################################################
     48    -->
    3449
    3550    <!-- bbPress follows only a subset of the WordPress Coding Standards Rules -->
    36 
    37 
    38     <!-- Rules that require further review, reviewed -->
     51    <rule ref="WordPress-Extra">
     52        <!-- Set the minimum supported WP version for all sniff which use it in one go.
     53             Ref: https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters
     54        -->
     55        <properties>
     56            <property name="minimum_supported_version" value="5.3"/>
     57        </properties>
     58
     59        <!-- Set the custom test class whitelist for all sniffs which use it in one go.
     60             Ref: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#custom-unit-test-classes
     61        -->
     62        <property name="custom_test_class_whitelist" type="array">
     63            <element value="BBP_UnitTestCase"/>
     64        </property>
     65
     66    </rule>
     67
     68    <!-- Check the code for PHP cross-version compatibility. -->
     69    <config name="testVersion" value="5.6-"/>
     70    <rule ref="PHPCompatibilityWP"/>
     71
     72
     73    <!--
     74    #############################################################################
     75    SNIFF SPECIFIC CONFIGURATION
     76    #############################################################################
     77    -->
     78
     79    <!-- Verify that all gettext calls use the correct text domain. -->
     80    <rule ref="WordPress.WP.I18n">
     81        <properties>
     82            <property name="text_domain" type="array">
     83                <element value="bbpress"/>
     84            </property>
     85        </properties>
     86    </rule>
     87
     88    <!-- Verify that everything in the global namespace is prefixed. -->
     89    <rule ref="WordPress.NamingConventions.PrefixAllGlobals">
     90        <properties>
     91            <property name="prefixes" type="array" extend="true">
     92                <element value="bbp"/>
     93            </property>
     94        </properties>
     95    </rule>
     96
     97    <rule ref="WordPress.Arrays.MultipleStatementAlignment">
     98        <properties>
     99            <!-- No need to adjust alignment of large arrays when the item with the largest key is removed. -->
     100            <property name="exact" value="false"/>
     101            <!-- Don't align multi-line items if ALL items in the array are multi-line. -->
     102            <property name="alignMultilineItems" value="!=100"/>
     103            <!-- Array Assignment operator should always be on the same line as the array key. -->
     104            <property name="ignoreNewlines" value="false"/>
     105        </properties>
     106    </rule>
     107
     108    <rule ref="WordPress.PHP.NoSilencedErrors">
     109        <properties>
     110            <property name="use_default_whitelist" value="true"/>
     111        </properties>
     112    </rule>
     113
     114
     115    <!--
     116    #############################################################################
     117    SELECTIVE EXCLUSIONS
     118    Exclude specific files for specific sniffs and/or exclude sub-groups in sniffs.
     119    #############################################################################
     120    -->
    39121
    40122    <rule ref="Generic.Formatting.MultipleStatementAlignment.IncorrectWarning">
     
    59141
    60142    <rule ref="PEAR.NamingConventions.ValidClassName.StartWithCapital">
    61         <exclude-pattern>/src/bbpress.php</exclude-pattern>
    62         <exclude-pattern>/src/includes/admin/converters/bbPress1.php</exclude-pattern>
    63         <exclude-pattern>/src/includes/admin/converters/e107v1.php</exclude-pattern>
    64         <exclude-pattern>/src/includes/admin/converters/phpBB.php</exclude-pattern>
    65         <exclude-pattern>/src/includes/admin/converters/vBulletin.php</exclude-pattern>
    66         <exclude-pattern>/src/includes/admin/converters/vBulletin3.php</exclude-pattern>
     143        <exclude-pattern>/src/bbpress\.php$</exclude-pattern>
     144        <exclude-pattern>/src/includes/admin/converters/bbPress1\.php$</exclude-pattern>
     145        <exclude-pattern>/src/includes/admin/converters/e107v1\.php$</exclude-pattern>
     146        <exclude-pattern>/src/includes/admin/converters/phpBB\.php$</exclude-pattern>
     147        <exclude-pattern>/src/includes/admin/converters/vBulletin\.php$</exclude-pattern>
     148        <exclude-pattern>/src/includes/admin/converters/vBulletin3\.php$</exclude-pattern>
    67149    </rule>
    68150
     
    79161    </rule>
    80162
     163
     164    <!--
     165    #############################################################################
     166    TEMPORARY ADJUSTMENTS
     167    Adjustments which should be removed once the associated issues have been reviewed and resolved.
     168    #############################################################################
     169    -->
     170
    81171    <!-- Rules that require further review, partially reviewed -->
    82172
     173    <rule ref="Generic.Formatting.DisallowMultipleStatements.SameLine">
     174        <exclude-pattern>/src/*</exclude-pattern>
     175    </rule>
     176
     177    <rule ref="Generic.Formatting.SpaceAfterCast.TooMuchSpace">
     178        <exclude-pattern>/src/*</exclude-pattern>
     179    </rule>
     180
     181    <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace">
     182        <exclude-pattern>/src/*</exclude-pattern>
     183    </rule>
     184
     185    <rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeClose">
     186        <exclude-pattern>/src/*</exclude-pattern>
     187    </rule>
     188
     189    <rule ref="PEAR.Functions.FunctionCallSignature.Indent">
     190        <exclude-pattern>/src/*</exclude-pattern>
     191    </rule>
     192
     193    <rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
     194        <exclude-pattern>/src/*</exclude-pattern>
     195    </rule>
     196
     197    <rule ref="PSR2.ControlStructures.SwitchDeclaration.BreakIndent">
     198        <exclude-pattern>/src/*</exclude-pattern>
     199    </rule>
     200
     201    <!-- Rules that require further review, not yet reviewed -->
     202
     203    <rule ref="Generic.CodeAnalysis.EmptyStatement.DetectedElseif">
     204        <exclude-pattern>/src/*</exclude-pattern>
     205    </rule>
     206
     207    <rule ref="Generic.CodeAnalysis.EmptyStatement.DetectedIf">
     208        <exclude-pattern>/src/*</exclude-pattern>
     209    </rule>
     210
     211    <rule ref="Generic.CodeAnalysis.UselessOverridingMethod.Found">
     212        <exclude-pattern>/src/*</exclude-pattern>
     213    </rule>
     214
    83215    <rule ref="Generic.ControlStructures.InlineControlStructure.NotAllowed">
    84216        <exclude-pattern>/src/*</exclude-pattern>
    85217    </rule>
    86218
    87     <rule ref="Generic.Formatting.DisallowMultipleStatements.SameLine">
    88         <exclude-pattern>/src/*</exclude-pattern>
    89     </rule>
    90 
    91     <rule ref="Generic.Formatting.SpaceAfterCast.TooMuchSpace">
    92         <exclude-pattern>/src/*</exclude-pattern>
    93     </rule>
    94 
    95     <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace">
    96         <exclude-pattern>/src/*</exclude-pattern>
    97     </rule>
    98 
    99     <rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeClose">
    100         <exclude-pattern>/src/*</exclude-pattern>
    101     </rule>
    102 
    103     <rule ref="PEAR.Functions.FunctionCallSignature.Indent">
    104         <exclude-pattern>/src/*</exclude-pattern>
    105     </rule>
    106 
    107     <rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
    108         <exclude-pattern>/src/*</exclude-pattern>
    109     </rule>
    110 
    111     <rule ref="PSR2.ControlStructures.SwitchDeclaration.BreakIndent">
    112         <exclude-pattern>/src/*</exclude-pattern>
    113     </rule>
    114 
    115     <!-- Rules that require further review, not yet reviewed -->
     219    <rule ref="Generic.Files.LineEndings.InvalidEOLChar">
     220        <exclude-pattern>/src/*</exclude-pattern>
     221    </rule>
     222
     223    <rule ref="Generic.Files.OneObjectStructurePerFile.MultipleFound">
     224        <exclude-pattern>/src/*</exclude-pattern>
     225    </rule>
     226
     227    <rule ref="PEAR.Files.IncludingFile.UseRequire">
     228        <exclude-pattern>/bbpress\.php$</exclude-pattern>
     229        <exclude-pattern>/src/*</exclude-pattern>
     230    </rule>
    116231
    117232    <rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
     
    123238    </rule>
    124239
     240    <rule ref="PEAR.Functions.FunctionCallSignature.FirstArgumentPosition">
     241        <exclude-pattern>/src/*</exclude-pattern>
     242    </rule>
     243
    125244    <rule ref="PEAR.Functions.FunctionCallSignature.MultipleArguments">
    126245        <exclude-pattern>/src/*</exclude-pattern>
     
    139258    </rule>
    140259
     260    <rule ref="PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.Changed">
     261        <exclude-pattern>/src/*</exclude-pattern>
     262    </rule>
     263
     264    <rule ref="PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection">
     265        <exclude-pattern>/src/*</exclude-pattern>
     266    </rule>
     267
     268    <rule ref="PHPCompatibility.Syntax.RemovedCurlyBraceArrayAccess.Found">
     269        <exclude-pattern>/src/*</exclude-pattern>
     270    </rule>
     271
     272    <rule ref="PSR2.Classes.PropertyDeclaration.ScopeMissing">
     273        <exclude-pattern>/src/*</exclude-pattern>
     274    </rule>
     275
     276    <rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
     277        <exclude-pattern>/src/*</exclude-pattern>
     278    </rule>
     279
     280    <rule ref="PSR2.Classes.PropertyDeclaration.VarUsed">
     281        <exclude-pattern>/src/*</exclude-pattern>
     282    </rule>
     283
    141284    <rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
    142285        <exclude-pattern>/src/*</exclude-pattern>
     
    159302    </rule>
    160303
     304    <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
     305        <exclude-pattern>/src/*</exclude-pattern>
     306    </rule>
     307
    161308    <rule ref="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace">
    162309        <exclude-pattern>/src/*</exclude-pattern>
     
    171318    </rule>
    172319
     320    <rule ref="Squiz.PHP.CommentedOutCode.Found">
     321        <exclude-pattern>/src/*</exclude-pattern>
     322    </rule>
     323
    173324    <rule ref="Squiz.PHP.DisallowMultipleAssignments.Found">
    174325        <exclude-pattern>/src/*</exclude-pattern>
     
    179330    </rule>
    180331
     332    <rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops.Found">
     333        <exclude-pattern>/src/*</exclude-pattern>
     334    </rule>
     335
    181336    <rule ref="Squiz.PHP.EmbeddedPhp.ContentAfterEnd">
    182337        <exclude-pattern>/src/*</exclude-pattern>
     
    195350    </rule>
    196351
     352    <rule ref="Squiz.PHP.NonExecutableCode.Unreachable">
     353        <exclude-pattern>/src/*</exclude-pattern>
     354    </rule>
     355
     356    <rule ref="Squiz.Scope.MethodScope.Missing">
     357        <exclude-pattern>/src/*</exclude-pattern>
     358    </rule>
     359
    197360    <rule ref="Squiz.Strings.ConcatenationSpacing.PaddingFound">
    198361        <exclude-pattern>/src/*</exclude-pattern>
     
    243406    </rule>
    244407
     408    <rule ref="WordPress.Arrays.ArrayKeySpacingRestrictions.TooMuchSpaceAfterKey">
     409        <exclude-pattern>/src/*</exclude-pattern>
     410    </rule>
     411
    245412    <rule ref="WordPress.Arrays.CommaAfterArrayItem.SpaceAfterComma">
    246413        <exclude-pattern>/src/*</exclude-pattern>
     
    251418    </rule>
    252419
     420    <rule ref="WordPress.Arrays.MultipleStatementAlignment.MultilineItemSpaceBeforeDoubleArrow">
     421        <exclude-pattern>/src/*</exclude-pattern>
     422    </rule>
     423
    253424    <rule ref="WordPress.Arrays.MultipleStatementAlignment.SpaceBeforeDoubleArrow">
    254425        <exclude-pattern>/src/*</exclude-pattern>
     
    267438    </rule>
    268439
     440    <rule ref="WordPress.DateTime.CurrentTimeTimestamp.Requested">
     441        <exclude-pattern>/src/*</exclude-pattern>
     442    </rule>
     443
     444    <rule ref="WordPress.DateTime.RestrictedFunctions.date_date">
     445        <exclude-pattern>/src/*</exclude-pattern>
     446    </rule>
     447
    269448    <rule ref="WordPress.DB.PreparedSQL.InterpolatedNotPrepared">
    270449        <exclude-pattern>/src/*</exclude-pattern>
     
    283462    </rule>
    284463
     464    <rule ref="WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound">
     465        <exclude-pattern>/src/*</exclude-pattern>
     466    </rule>
     467
     468    <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound">
     469        <exclude-pattern>/src/*</exclude-pattern>
     470    </rule>
     471
     472    <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound">
     473        <exclude-pattern>/src/*</exclude-pattern>
     474    </rule>
     475
     476    <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound">
     477        <exclude-pattern>/src/*</exclude-pattern>
     478    </rule>
     479
     480    <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound">
     481        <exclude-pattern>/src/*</exclude-pattern>
     482    </rule>
     483
     484    <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound">
     485        <exclude-pattern>/src/*</exclude-pattern>
     486    </rule>
     487
    285488    <rule ref="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid">
    286489        <exclude-pattern>/src/*</exclude-pattern>
     
    291494    </rule>
    292495
     496    <rule ref="WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize">
     497        <exclude-pattern>/src/*</exclude-pattern>
     498    </rule>
     499
     500    <rule ref="WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize">
     501        <exclude-pattern>/src/*</exclude-pattern>
     502    </rule>
     503
     504    <rule ref="WordPress.PHP.DiscouragedPHPFunctions.urlencode_urlencode">
     505        <exclude-pattern>/src/*</exclude-pattern>
     506    </rule>
     507
     508    <rule ref="WordPress.PHP.IniSet.Risky">
     509        <exclude-pattern>/src/*</exclude-pattern>
     510    </rule>
     511
    293512    <rule ref="WordPress.PHP.NoSilencedErrors.Discouraged">
    294513        <exclude-pattern>/src/*</exclude-pattern>
    295514    </rule>
    296515
     516    <rule ref="WordPress.PHP.PregQuoteDelimiter.Missing">
     517        <exclude-pattern>/src/*</exclude-pattern>
     518    </rule>
     519
    297520    <rule ref="WordPress.PHP.StrictComparisons.LooseComparison">
    298521        <exclude-pattern>/src/*</exclude-pattern>
     
    307530    </rule>
    308531
     532    <rule ref="WordPress.Security.EscapeOutput.OutputNotEscaped">
     533        <exclude-pattern>/src/*</exclude-pattern>
     534    </rule>
     535
     536    <rule ref="WordPress.Security.EscapeOutput.UnsafePrintingFunction">
     537        <exclude-pattern>/src/*</exclude-pattern>
     538    </rule>
     539
     540    <rule ref="WordPress.Security.NonceVerification.Missing">
     541        <exclude-pattern>/src/*</exclude-pattern>
     542    </rule>
     543
     544    <rule ref="WordPress.Security.NonceVerification.Recommended">
     545        <exclude-pattern>/src/*</exclude-pattern>
     546    </rule>
     547
    309548    <rule ref="WordPress.WhiteSpace.ControlStructureSpacing.ExtraSpaceAfterCloseParenthesis">
    310549        <exclude-pattern>/src/*</exclude-pattern>
     
    347586    </rule>
    348587
     588    <rule ref="WordPress.WP.AlternativeFunctions.json_encode_json_encode">
     589        <exclude-pattern>/src/*</exclude-pattern>
     590    </rule>
     591
     592    <rule ref="WordPress.WP.AlternativeFunctions.parse_url_parse_url">
     593        <exclude-pattern>/src/*</exclude-pattern>
     594    </rule>
     595
     596    <rule ref="WordPress.WP.AlternativeFunctions.rand_mt_rand">
     597        <exclude-pattern>/src/*</exclude-pattern>
     598    </rule>
     599
     600    <rule ref="WordPress.WP.AlternativeFunctions.strip_tags_strip_tags">
     601        <exclude-pattern>/src/*</exclude-pattern>
     602    </rule>
     603
     604    <rule ref="WordPress.WP.DiscouragedFunctions.query_posts_query_posts">
     605        <exclude-pattern>/src/*</exclude-pattern>
     606    </rule>
     607
     608    <rule ref="WordPress.WP.DiscouragedFunctions.wp_reset_query_wp_reset_query">
     609        <exclude-pattern>/src/*</exclude-pattern>
     610    </rule>
     611
     612    <rule ref="WordPress.WP.EnqueuedResourceParameters.NotInFooter">
     613        <exclude-pattern>/src/*</exclude-pattern>
     614    </rule>
     615
     616    <rule ref="WordPress.WP.GlobalVariablesOverride.Prohibited">
     617        <exclude-pattern>/src/*</exclude-pattern>
     618    </rule>
     619
    349620    <rule ref="WordPress.WP.I18n.LowLevelTranslationFunction">
    350621        <exclude-pattern>/src/*</exclude-pattern>
  • trunk/src/includes/admin/converters/Invision.php

    r7014 r7050  
    542542    private function to_char( $input ) {
    543543        $output = '';
    544         for ( $i = 0; $i < strlen( $input ); $i++ ) {
     544        $length = strlen( $input );
     545        for ( $i = 0; $i < $length; $i++ ) {
    545546            $j = ord( $input[$i] );
    546547            if ( ( $j >= 65 && $j <= 90 )
Note: See TracChangeset for help on using the changeset viewer.