Skip to content

Commit 40fc69a

Browse files
PHPCS: Add new ruleset to the project
1 parent 0d33652 commit 40fc69a

File tree

4 files changed

+48
-49
lines changed

4 files changed

+48
-49
lines changed

.distignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
.editorconfig
66
.travis.yml
77
circle.yml
8+
phpcs.xml.dist
9+
phpunit.xml.dist
810
bin/
911
features/
1012
utils/

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ vendor/
66
*.zip
77
*.tar.gz
88
*.log
9+
phpunit.xml
10+
phpcs.xml
11+
.phpcs.xml

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"wp-cli/wp-cli": "^2"
1111
},
1212
"require-dev": {
13-
"wp-cli/wp-cli-tests": "^2.0.7"
13+
"wp-cli/wp-cli-tests": "^2.1"
1414
},
1515
"config": {
1616
"process-timeout": 7200,

phpcs.xml.dist

Lines changed: 42 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,54 @@
11
<?xml version="1.0"?>
2-
<ruleset name="WP-CLI">
3-
<description>Custom ruleset for WP-CLI</description>
2+
<ruleset name="WP-CLI-find">
3+
<description>Custom ruleset for WP-CLI profile-command</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>
415

5-
<!-- For help in understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
6-
<!-- For help in using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
16+
<!-- Show progress. -->
17+
<arg value="p"/>
718

8-
<!-- What to scan -->
9-
<file>.</file>
10-
<!-- Ignoring Files and Folders:
11-
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->
12-
<exclude-pattern>*/.git/*</exclude-pattern>
13-
<exclude-pattern>*/ci/*</exclude-pattern>
14-
<exclude-pattern>*/features/*</exclude-pattern>
15-
<exclude-pattern>*/packages/*</exclude-pattern>
16-
<exclude-pattern>*/tests/*</exclude-pattern>
17-
<exclude-pattern>*/utils/*</exclude-pattern>
18-
<exclude-pattern>*/vendor/*</exclude-pattern>
19-
20-
<!-- How to scan -->
21-
<arg value="sp"/> <!-- Show sniff and progress -->
22-
<arg name="colors"/> <!-- Show results with colors -->
23-
<arg name="extensions" value="php"/> <!-- Limit to PHP files -->
24-
25-
<!-- Rules: Check PHP version compatibility - see
26-
https://github.com/PHPCompatibility/PHPCompatibilityWP -->
27-
<rule ref="PHPCompatibilityWP">
28-
<!-- Polyfill package is used so array_column() is available for PHP 5.4- -->
29-
<exclude name="PHPCompatibility.PHP.NewFunctions.array_columnFound"/>
30-
<!-- Both magic quotes directives set in wp-settings-cli.php to provide consistent starting point. -->
31-
<exclude name="PHPCompatibility.PHP.DeprecatedIniDirectives.magic_quotes_runtimeDeprecatedRemoved"/>
32-
<exclude name="PHPCompatibility.PHP.DeprecatedIniDirectives.magic_quotes_sybaseDeprecatedRemoved"/>
33-
</rule>
19+
<!-- Strip the filepaths down to the relevant bit. -->
20+
<arg name="basepath" value="./"/>
3421

35-
<!-- For help in understanding this testVersion:
36-
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
37-
<config name="testVersion" value="5.4-"/>
22+
<!-- Check up to 8 files simultaneously. -->
23+
<arg name="parallel" value="8"/>
3824

39-
<!-- Ignore php_uname mode issue, we're conditionally providing a callback -->
40-
<rule ref="PHPCompatibility.PHP.NewFunctionParameters.php_uname_modeFound">
41-
<exclude-pattern>*/php/commands/src/CLI_Command.php</exclude-pattern>
42-
</rule>
25+
<!--
26+
#############################################################################
27+
USE THE WP_CLI_CS RULESET
28+
#############################################################################
29+
-->
4330

44-
<!-- Rules: WordPress Coding Standards - see
45-
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
46-
<rule ref="WordPress-Core">
47-
<exclude name="Squiz.PHP.DisallowMultipleAssignments.Found" />
48-
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar" />
49-
<exclude name="WordPress.NamingConventions.ValidVariableName.MemberNotSnakeCase" />
50-
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCase" />
51-
</rule>
31+
<rule ref="WP_CLI_CS"/>
32+
33+
<!--
34+
#############################################################################
35+
PROJECT SPECIFIC CONFIGURATION FOR SNIFFS
36+
#############################################################################
37+
-->
38+
39+
<!-- For help understanding the `testVersion` configuration setting:
40+
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
41+
<config name="testVersion" value="5.4-"/>
5242

53-
<!-- For help in understanding these custom sniff properties:
54-
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
55-
<rule ref="WordPress.Files.FileName">
43+
<!-- Verify that everything in the global namespace is either namespaced or prefixed.
44+
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->
45+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
5646
<properties>
5747
<property name="strict_class_file_names" value="false"/>
48+
<property name="prefixes" type="array">
49+
<element value="WP_CLI\Profile"/><!-- Namespaces. -->
50+
<element value="wpcli_profile"/><!-- Global variables and such. -->
51+
</property>
5852
</properties>
5953
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
6054
</rule>

0 commit comments

Comments
 (0)