Skip to:
Content

bbPress.org

Ticket #3294: trac-3294-setup-phpcs.2.patch

File trac-3294-setup-phpcs.2.patch, 16.8 KB (added by jrf, 23 months ago)

Replacement patch. Earlier patch was missing one change.

  • composer.json

     
     1{
     2    "require-dev": {
     3        "phpcompatibility/phpcompatibility-wp": "^2.1",
     4        "wp-coding-standards/wpcs": "^2.2",
     5        "dealerdirect/phpcodesniffer-composer-installer": "^0.5"
     6    },
     7    "minimum-stability": "dev",
     8    "prefer-stable": true,
     9    "scripts": {
     10        "check-cs": [
     11            "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --runtime-set ignore_warnings_on_exit 1"
     12        ],
     13        "fix-cs": [
     14            "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"
     15        ]
     16    }
     17}
  • Gruntfile.js

    Property changes on: composer.json
    ___________________________________________________________________
    Added: svn:eol-style
    ## -0,0 +1 ##
    +LF
    \ No newline at end of property
     
    224224                phpcs: {
    225225                        'default': {
    226226                                cmd: 'phpcs',
    227                                 args: [ '--standard=phpcs.xml.dist', '--report-summary', '--report-source', '--cache=.phpcscache' ]
     227                                args: [ '--report-summary,source', '--cache=.phpcscache' ]
    228228                        }
    229229                },
    230230                phpunit: {
  • .gitignore

     
    99/node_modules
    1010/npm-debug.log
    1111.phpcscache
     12.phpcs.xml
     13phpcs.xml
     14composer.lock
     15/vendor/
    1216
    1317# Output directory.
    1418/build
  • phpcs.xml.dist

     
    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>
     2<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     3        name="bbPress"
     4        xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
    45
    5         <rule ref="WordPress-Core"/>
     6        <description>Apply WordPress Coding Standards to all Core files with specific bbPress exclusions</description>
    67
    7         <arg name="extensions" value="php"/>
     8        <!--
     9        #############################################################################
     10        COMMAND LINE ARGUMENTS
     11        https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
     12        #############################################################################
     13        -->
    814
    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"/>
    17 
    1815        <file>.</file>
    1916
    2017        <!-- Test data and fixtures -->
     
    3027        <exclude-pattern type="relative">^build/*</exclude-pattern>
    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>
    3431
     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        -->
     49
    3550        <!-- bbPress follows only a subset of the WordPress Coding Standards Rules -->
     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>
    3658
     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>
    3765
    38         <!-- Rules that require further review, reviewed -->
     66        </rule>
    3967
     68        <!-- Check the code for PHP cross-version compatibility. -->
     69        <config name="testVersion" value="5.6-"/>
     70        <rule ref="PHPCompatibilityWP">
     71                <include-pattern>*\.php$</include-pattern>
     72        </rule>
     73
     74
     75        <!--
     76        #############################################################################
     77        SNIFF SPECIFIC CONFIGURATION
     78        #############################################################################
     79        -->
     80
     81        <!-- Verify that all gettext calls use the correct text domain. -->
     82        <rule ref="WordPress.WP.I18n">
     83                <properties>
     84                        <property name="text_domain" type="array">
     85                                <element value="bbpress"/>
     86                        </property>
     87                </properties>
     88        </rule>
     89
     90        <!-- Verify that everything in the global namespace is prefixed. -->
     91        <rule ref="WordPress.NamingConventions.PrefixAllGlobals">
     92                <properties>
     93                        <property name="prefixes" type="array" extend="true">
     94                                <element value="bbp"/>
     95                        </property>
     96                </properties>
     97        </rule>
     98
     99        <rule ref="WordPress.Arrays.MultipleStatementAlignment">
     100                <properties>
     101                        <!-- No need to adjust alignment of large arrays when the item with the largest key is removed. -->
     102                        <property name="exact" value="false"/>
     103                        <!-- Don't align multi-line items if ALL items in the array are multi-line. -->
     104                        <property name="alignMultilineItems" value="!=100"/>
     105                        <!-- Array Assignment operator should always be on the same line as the array key. -->
     106                        <property name="ignoreNewlines" value="false"/>
     107                </properties>
     108        </rule>
     109
     110
     111        <!--
     112        #############################################################################
     113        SELECTIVE EXCLUSIONS
     114        Exclude specific files for specific sniffs and/or exclude sub-groups in sniffs.
     115        #############################################################################
     116        -->
     117
    40118        <rule ref="Generic.Formatting.MultipleStatementAlignment.IncorrectWarning">
    41119                <exclude-pattern>/src/*</exclude-pattern>
    42120        </rule>
     
    58136        </rule>
    59137
    60138        <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>
     139                <exclude-pattern>/src/bbpress\.php$</exclude-pattern>
     140                <exclude-pattern>/src/includes/admin/converters/bbPress1\.php$</exclude-pattern>
     141                <exclude-pattern>/src/includes/admin/converters/e107v1\.php$</exclude-pattern>
     142                <exclude-pattern>/src/includes/admin/converters/phpBB\.php$</exclude-pattern>
     143                <exclude-pattern>/src/includes/admin/converters/vBulletin\.php$</exclude-pattern>
     144                <exclude-pattern>/src/includes/admin/converters/vBulletin3\.php$</exclude-pattern>
    67145        </rule>
    68146
    69147        <rule ref="Squiz.PHP.EmbeddedPhp.ContentBeforeEnd">
     
    78156                <exclude-pattern>/src/*</exclude-pattern>
    79157        </rule>
    80158
     159
     160        <!--
     161        #############################################################################
     162        TEMPORARY ADJUSTMENTS
     163        Adjustments which should be removed once the associated issues have been reviewed and resolved.
     164        #############################################################################
     165        -->
     166
    81167        <!-- Rules that require further review, partially reviewed -->
    82168
    83169        <rule ref="Generic.ControlStructures.InlineControlStructure.NotAllowed">
     
    114200
    115201        <!-- Rules that require further review, not yet reviewed -->
    116202
     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.ForLoopWithTestFunctionCall.NotAllowed">
     212                <exclude-pattern>/src/*</exclude-pattern>
     213        </rule>
     214
     215        <rule ref="Generic.CodeAnalysis.UselessOverridingMethod.Found">
     216                <exclude-pattern>/src/*</exclude-pattern>
     217        </rule>
     218
     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>
     231
    117232        <rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
    118233                <exclude-pattern>/src/*</exclude-pattern>
    119234        </rule>
     
    122237                <exclude-pattern>/src/*</exclude-pattern>
    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>
    127246        </rule>
     
    138257                <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.Underscore">
     273                <exclude-pattern>/src/*</exclude-pattern>
     274        </rule>
     275
     276        <rule ref="PSR2.Classes.PropertyDeclaration.ScopeMissing">
     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>
    143286        </rule>
     
    158301                <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>
    163310        </rule>
     
    170317                <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>
    175326        </rule>
     
    178329                <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>
    183338        </rule>
     
    194349                <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>
    199362        </rule>
     
    242405                <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>
    247414        </rule>
     
    250417                <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>
    255426        </rule>
    256427
     428        <rule ref="WordPress.Classes.ClassInstantiation.MissingParenthesis">
     429                <exclude-pattern>/src/*</exclude-pattern>
     430        </rule>
     431
    257432        <rule ref="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition">
    258433                <exclude-pattern>/src/*</exclude-pattern>
    259434        </rule>
     
    266441                <exclude-pattern>/src/*</exclude-pattern>
    267442        </rule>
    268443
     444        <rule ref="WordPress.DateTime.CurrentTimeTimestamp.Requested">
     445                <exclude-pattern>/src/*</exclude-pattern>
     446        </rule>
     447
     448        <rule ref="WordPress.DateTime.RestrictedFunctions.date_date">
     449                <exclude-pattern>/src/*</exclude-pattern>
     450        </rule>
     451
    269452        <rule ref="WordPress.DB.PreparedSQL.InterpolatedNotPrepared">
    270453                <exclude-pattern>/src/*</exclude-pattern>
    271454        </rule>
     
    282465                <exclude-pattern>/src/*</exclude-pattern>
    283466        </rule>
    284467
     468        <rule ref="WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound">
     469                <exclude-pattern>/src/*</exclude-pattern>
     470        </rule>
     471
     472        <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound">
     473                <exclude-pattern>/src/*</exclude-pattern>
     474        </rule>
     475
     476        <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound">
     477                <exclude-pattern>/src/*</exclude-pattern>
     478        </rule>
     479
     480        <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound">
     481                <exclude-pattern>/src/*</exclude-pattern>
     482        </rule>
     483
     484        <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound">
     485                <exclude-pattern>/src/*</exclude-pattern>
     486        </rule>
     487
     488        <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound">
     489                <exclude-pattern>/src/*</exclude-pattern>
     490        </rule>
     491
    285492        <rule ref="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid">
    286493                <exclude-pattern>/src/*</exclude-pattern>
    287494        </rule>
     
    290497                <exclude-pattern>/src/*</exclude-pattern>
    291498        </rule>
    292499
     500        <rule ref="WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize">
     501                <exclude-pattern>/src/*</exclude-pattern>
     502        </rule>
     503
     504        <rule ref="WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize">
     505                <exclude-pattern>/src/*</exclude-pattern>
     506        </rule>
     507
     508        <rule ref="WordPress.PHP.DiscouragedPHPFunctions.urlencode_urlencode">
     509                <exclude-pattern>/src/*</exclude-pattern>
     510        </rule>
     511
     512        <rule ref="WordPress.PHP.IniSet.Risky">
     513                <exclude-pattern>/src/*</exclude-pattern>
     514        </rule>
     515
    293516        <rule ref="WordPress.PHP.NoSilencedErrors.Discouraged">
    294517                <exclude-pattern>/src/*</exclude-pattern>
    295518        </rule>
    296519
     520        <rule ref="WordPress.PHP.PregQuoteDelimiter.Missing">
     521                <exclude-pattern>/src/*</exclude-pattern>
     522        </rule>
     523
    297524        <rule ref="WordPress.PHP.StrictComparisons.LooseComparison">
    298525                <exclude-pattern>/src/*</exclude-pattern>
    299526        </rule>
     
    306533                <exclude-pattern>/src/*</exclude-pattern>
    307534        </rule>
    308535
     536        <rule ref="WordPress.Security.EscapeOutput.OutputNotEscaped">
     537                <exclude-pattern>/src/*</exclude-pattern>
     538        </rule>
     539
     540        <rule ref="WordPress.Security.EscapeOutput.UnsafePrintingFunction">
     541                <exclude-pattern>/src/*</exclude-pattern>
     542        </rule>
     543
     544        <rule ref="WordPress.Security.NonceVerification.Missing">
     545                <exclude-pattern>/src/*</exclude-pattern>
     546        </rule>
     547
     548        <rule ref="WordPress.Security.NonceVerification.Recommended">
     549                <exclude-pattern>/src/*</exclude-pattern>
     550        </rule>
     551
    309552        <rule ref="WordPress.WhiteSpace.ControlStructureSpacing.ExtraSpaceAfterCloseParenthesis">
    310553                <exclude-pattern>/src/*</exclude-pattern>
    311554        </rule>
     
    346589                <exclude-pattern>/src/*</exclude-pattern>
    347590        </rule>
    348591
     592        <rule ref="WordPress.WP.AlternativeFunctions.json_encode_json_encode">
     593                <exclude-pattern>/src/*</exclude-pattern>
     594        </rule>
     595
     596        <rule ref="WordPress.WP.AlternativeFunctions.parse_url_parse_url">
     597                <exclude-pattern>/src/*</exclude-pattern>
     598        </rule>
     599
     600        <rule ref="WordPress.WP.AlternativeFunctions.rand_mt_rand">
     601                <exclude-pattern>/src/*</exclude-pattern>
     602        </rule>
     603
     604        <rule ref="WordPress.WP.AlternativeFunctions.strip_tags_strip_tags">
     605                <exclude-pattern>/src/*</exclude-pattern>
     606        </rule>
     607
     608        <rule ref="WordPress.WP.DiscouragedFunctions.query_posts_query_posts">
     609                <exclude-pattern>/src/*</exclude-pattern>
     610        </rule>
     611
     612        <rule ref="WordPress.WP.DiscouragedFunctions.wp_reset_query_wp_reset_query">
     613                <exclude-pattern>/src/*</exclude-pattern>
     614        </rule>
     615
     616        <rule ref="WordPress.WP.EnqueuedResourceParameters.NotInFooter">
     617                <exclude-pattern>/src/*</exclude-pattern>
     618        </rule>
     619
     620        <rule ref="WordPress.WP.GlobalVariablesOverride.Prohibited">
     621                <exclude-pattern>/src/*</exclude-pattern>
     622        </rule>
     623
    349624        <rule ref="WordPress.WP.I18n.LowLevelTranslationFunction">
    350625                <exclude-pattern>/src/*</exclude-pattern>
    351626        </rule>