Ticket #3294: trac-3294-setup-phpcs.2.patch
File trac-3294-setup-phpcs.2.patch, 16.8 KB (added by , 5 years ago) |
---|
-
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
224 224 phpcs: { 225 225 'default': { 226 226 cmd: 'phpcs', 227 args: [ '-- standard=phpcs.xml.dist', '--report-summary', '--report-source', '--cache=.phpcscache' ]227 args: [ '--report-summary,source', '--cache=.phpcscache' ] 228 228 } 229 229 }, 230 230 phpunit: { -
.gitignore
9 9 /node_modules 10 10 /npm-debug.log 11 11 .phpcscache 12 .phpcs.xml 13 phpcs.xml 14 composer.lock 15 /vendor/ 12 16 13 17 # Output directory. 14 18 /build -
phpcs.xml.dist
1 1 <?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"> 4 5 5 < rule ref="WordPress-Core"/>6 <description>Apply WordPress Coding Standards to all Core files with specific bbPress exclusions</description> 6 7 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 --> 8 14 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 18 15 <file>.</file> 19 16 20 17 <!-- Test data and fixtures --> … … 30 27 <exclude-pattern type="relative">^build/*</exclude-pattern> 31 28 32 29 <!-- 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> 34 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 --> 49 35 50 <!-- 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> 36 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> 37 65 38 < !-- Rules that require further review, reviewed -->66 </rule> 39 67 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 40 118 <rule ref="Generic.Formatting.MultipleStatementAlignment.IncorrectWarning"> 41 119 <exclude-pattern>/src/*</exclude-pattern> 42 120 </rule> … … 58 136 </rule> 59 137 60 138 <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> 67 145 </rule> 68 146 69 147 <rule ref="Squiz.PHP.EmbeddedPhp.ContentBeforeEnd"> … … 78 156 <exclude-pattern>/src/*</exclude-pattern> 79 157 </rule> 80 158 159 160 <!-- 161 ############################################################################# 162 TEMPORARY ADJUSTMENTS 163 Adjustments which should be removed once the associated issues have been reviewed and resolved. 164 ############################################################################# 165 --> 166 81 167 <!-- Rules that require further review, partially reviewed --> 82 168 83 169 <rule ref="Generic.ControlStructures.InlineControlStructure.NotAllowed"> … … 114 200 115 201 <!-- Rules that require further review, not yet reviewed --> 116 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.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 117 232 <rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine"> 118 233 <exclude-pattern>/src/*</exclude-pattern> 119 234 </rule> … … 122 237 <exclude-pattern>/src/*</exclude-pattern> 123 238 </rule> 124 239 240 <rule ref="PEAR.Functions.FunctionCallSignature.FirstArgumentPosition"> 241 <exclude-pattern>/src/*</exclude-pattern> 242 </rule> 243 125 244 <rule ref="PEAR.Functions.FunctionCallSignature.MultipleArguments"> 126 245 <exclude-pattern>/src/*</exclude-pattern> 127 246 </rule> … … 138 257 <exclude-pattern>/src/*</exclude-pattern> 139 258 </rule> 140 259 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 141 284 <rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed"> 142 285 <exclude-pattern>/src/*</exclude-pattern> 143 286 </rule> … … 158 301 <exclude-pattern>/src/*</exclude-pattern> 159 302 </rule> 160 303 304 <rule ref="PSR2.Methods.MethodDeclaration.Underscore"> 305 <exclude-pattern>/src/*</exclude-pattern> 306 </rule> 307 161 308 <rule ref="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"> 162 309 <exclude-pattern>/src/*</exclude-pattern> 163 310 </rule> … … 170 317 <exclude-pattern>/src/*</exclude-pattern> 171 318 </rule> 172 319 320 <rule ref="Squiz.PHP.CommentedOutCode.Found"> 321 <exclude-pattern>/src/*</exclude-pattern> 322 </rule> 323 173 324 <rule ref="Squiz.PHP.DisallowMultipleAssignments.Found"> 174 325 <exclude-pattern>/src/*</exclude-pattern> 175 326 </rule> … … 178 329 <exclude-pattern>/src/*</exclude-pattern> 179 330 </rule> 180 331 332 <rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops.Found"> 333 <exclude-pattern>/src/*</exclude-pattern> 334 </rule> 335 181 336 <rule ref="Squiz.PHP.EmbeddedPhp.ContentAfterEnd"> 182 337 <exclude-pattern>/src/*</exclude-pattern> 183 338 </rule> … … 194 349 <exclude-pattern>/src/*</exclude-pattern> 195 350 </rule> 196 351 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 197 360 <rule ref="Squiz.Strings.ConcatenationSpacing.PaddingFound"> 198 361 <exclude-pattern>/src/*</exclude-pattern> 199 362 </rule> … … 242 405 <exclude-pattern>/src/*</exclude-pattern> 243 406 </rule> 244 407 408 <rule ref="WordPress.Arrays.ArrayKeySpacingRestrictions.TooMuchSpaceAfterKey"> 409 <exclude-pattern>/src/*</exclude-pattern> 410 </rule> 411 245 412 <rule ref="WordPress.Arrays.CommaAfterArrayItem.SpaceAfterComma"> 246 413 <exclude-pattern>/src/*</exclude-pattern> 247 414 </rule> … … 250 417 <exclude-pattern>/src/*</exclude-pattern> 251 418 </rule> 252 419 420 <rule ref="WordPress.Arrays.MultipleStatementAlignment.MultilineItemSpaceBeforeDoubleArrow"> 421 <exclude-pattern>/src/*</exclude-pattern> 422 </rule> 423 253 424 <rule ref="WordPress.Arrays.MultipleStatementAlignment.SpaceBeforeDoubleArrow"> 254 425 <exclude-pattern>/src/*</exclude-pattern> 255 426 </rule> 256 427 428 <rule ref="WordPress.Classes.ClassInstantiation.MissingParenthesis"> 429 <exclude-pattern>/src/*</exclude-pattern> 430 </rule> 431 257 432 <rule ref="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"> 258 433 <exclude-pattern>/src/*</exclude-pattern> 259 434 </rule> … … 266 441 <exclude-pattern>/src/*</exclude-pattern> 267 442 </rule> 268 443 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 269 452 <rule ref="WordPress.DB.PreparedSQL.InterpolatedNotPrepared"> 270 453 <exclude-pattern>/src/*</exclude-pattern> 271 454 </rule> … … 282 465 <exclude-pattern>/src/*</exclude-pattern> 283 466 </rule> 284 467 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 285 492 <rule ref="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"> 286 493 <exclude-pattern>/src/*</exclude-pattern> 287 494 </rule> … … 290 497 <exclude-pattern>/src/*</exclude-pattern> 291 498 </rule> 292 499 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 293 516 <rule ref="WordPress.PHP.NoSilencedErrors.Discouraged"> 294 517 <exclude-pattern>/src/*</exclude-pattern> 295 518 </rule> 296 519 520 <rule ref="WordPress.PHP.PregQuoteDelimiter.Missing"> 521 <exclude-pattern>/src/*</exclude-pattern> 522 </rule> 523 297 524 <rule ref="WordPress.PHP.StrictComparisons.LooseComparison"> 298 525 <exclude-pattern>/src/*</exclude-pattern> 299 526 </rule> … … 306 533 <exclude-pattern>/src/*</exclude-pattern> 307 534 </rule> 308 535 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 309 552 <rule ref="WordPress.WhiteSpace.ControlStructureSpacing.ExtraSpaceAfterCloseParenthesis"> 310 553 <exclude-pattern>/src/*</exclude-pattern> 311 554 </rule> … … 346 589 <exclude-pattern>/src/*</exclude-pattern> 347 590 </rule> 348 591 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 349 624 <rule ref="WordPress.WP.I18n.LowLevelTranslationFunction"> 350 625 <exclude-pattern>/src/*</exclude-pattern> 351 626 </rule>