|
| 1 | +<?xml version="1.0"?> |
| 2 | +<ruleset name="WP-CLI"> |
| 3 | + <description>Custom ruleset for WP-CLI</description> |
| 4 | + |
| 5 | + <!-- |
| 6 | + ############################################################################# |
| 7 | + COMMAND LINE ARGUMENTS |
| 8 | + For help understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml |
| 9 | + For help using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage |
| 10 | + ############################################################################# |
| 11 | + --> |
| 12 | + |
| 13 | + <!-- What to scan. --> |
| 14 | + <file>.</file> |
| 15 | + |
| 16 | + <!-- Ignoring select files/folders. |
| 17 | + https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders --> |
| 18 | + <exclude-pattern>*/tests/data/*</exclude-pattern> |
| 19 | + |
| 20 | + <!-- Show progress. --> |
| 21 | + <arg value="p"/> |
| 22 | + |
| 23 | + <!-- Strip the filepaths down to the relevant bit. --> |
| 24 | + <arg name="basepath" value="./"/> |
| 25 | + |
| 26 | + <!-- Check up to 8 files simultaneously. --> |
| 27 | + <arg name="parallel" value="8"/> |
| 28 | + |
| 29 | + <!-- |
| 30 | + ############################################################################# |
| 31 | + USE THE WP_CLI_CS RULESET |
| 32 | + ############################################################################# |
| 33 | + --> |
| 34 | + |
| 35 | + <rule ref="WP_CLI_CS"> |
| 36 | + <!-- The `while` control structure is the only one where assignments in conditions are mostly valid. --> |
| 37 | + <exclude name="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/> |
| 38 | + |
| 39 | + <!-- This is a bug in PHPCS. A fix for which has been pulled already and is expected to be |
| 40 | + merged in PHPCS 3.5.0. Once this repos upgrades to that version, this exclusion |
| 41 | + should be removed. --> |
| 42 | + <exclude name="PSR2.Namespaces.NamespaceDeclaration.BlankLineAfter"/> |
| 43 | + </rule> |
| 44 | + |
| 45 | + <!-- |
| 46 | + ############################################################################# |
| 47 | + PROJECT SPECIFIC CONFIGURATION FOR SNIFFS |
| 48 | + ############################################################################# |
| 49 | + --> |
| 50 | + |
| 51 | + <!-- For help understanding the `testVersion` configuration setting: |
| 52 | + https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions --> |
| 53 | + <config name="testVersion" value="5.6-"/> |
| 54 | + |
| 55 | + <!-- Verify that everything in the global namespace is either namespaced or prefixed. |
| 56 | + The default prefixes `WP_CLI` (for namespaces and classes) and `wpcli` (for variables) are inherited |
| 57 | + from the ruleset. This adds one additional allowed prefix specifically for hooks (though |
| 58 | + not automatically limited to them). |
| 59 | + See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace --> |
| 60 | + <rule ref="WordPress.NamingConventions.PrefixAllGlobals"> |
| 61 | + <properties> |
| 62 | + <property name="prefixes" type="array" extend="true"> |
| 63 | + <element value="cli_"/><!-- Hooks. --> |
| 64 | + </property> |
| 65 | + </properties> |
| 66 | + </rule> |
| 67 | + |
| 68 | + <!-- Whitelist the Utils\mysql_host_to_cli_args() method. |
| 69 | + See: https://github.com/phpcompatibility/phpcompatibility#phpcompatibility-specific-options --> |
| 70 | + <rule ref="PHPCompatibility.Extensions.RemovedExtensions"> |
| 71 | + <properties> |
| 72 | + <property name="functionWhitelist" type="array"> |
| 73 | + <element value="mysql_host_to_cli_args"/> |
| 74 | + </property> |
| 75 | + </properties> |
| 76 | + </rule> |
| 77 | + |
| 78 | + <!-- Allow for back-compat conversion comments to be explained in logical shorthand. |
| 79 | + See: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties#squizphpcommentedoutcode --> |
| 80 | + <rule ref="Squiz.PHP.CommentedOutCode"> |
| 81 | + <properties> |
| 82 | + <property name="maxPercentage" value="45"/> |
| 83 | + </properties> |
| 84 | + </rule> |
| 85 | + |
| 86 | + <!-- |
| 87 | + ############################################################################# |
| 88 | + SELECTIVE EXCLUSIONS |
| 89 | + ############################################################################# |
| 90 | + --> |
| 91 | + |
| 92 | + <!-- Exclude existing classes from the prefix rule as it would break BC to prefix them now. --> |
| 93 | + <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound"> |
| 94 | + <exclude-pattern>*/php/commands/src/CLI_(Cache_)?Command\.php$</exclude-pattern> |
| 95 | + <exclude-pattern>*/php/commands/src/Help_Command\.php$</exclude-pattern> |
| 96 | + <exclude-pattern>*/utils/contrib-list\.php$</exclude-pattern> |
| 97 | + </rule> |
| 98 | + |
| 99 | + <!-- Exclude existing classes from the prefix rule as it would break BC to prefix them now. --> |
| 100 | + <rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound"> |
| 101 | + <exclude-pattern>php/wp-settings-cli\.php$</exclude-pattern> |
| 102 | + </rule> |
| 103 | + |
| 104 | + <!-- These are all to do with file-system related tests. Just ignore them. --> |
| 105 | + <rule ref="WordPress.WP.CapitalPDangit"> |
| 106 | + <exclude-pattern>*/tests/test-(extractor|utils)\.php$</exclude-pattern> |
| 107 | + </rule> |
| 108 | + |
| 109 | + <!-- Allow for select data providers for tests to use single-line associative arrays. --> |
| 110 | + <rule ref="WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound"> |
| 111 | + <exclude-pattern>*/tests/test-(process|utils)\.php$</exclude-pattern> |
| 112 | + </rule> |
| 113 | + |
| 114 | + <!-- This is a procedural stand-alone file that is never loaded in a WordPress context, |
| 115 | + so this file does not have to comply with WP naming conventions. --> |
| 116 | + <rule ref="WordPress.NamingConventions.PrefixAllGlobals"> |
| 117 | + <exclude-pattern>*/utils/get-package-require-from-composer\.php$</exclude-pattern> |
| 118 | + </rule> |
| 119 | + |
| 120 | +</ruleset> |
0 commit comments