Skip to content

Commit c3e0a3a

Browse files
authored
Merge branch 'master' into 0.4.0-changelog
2 parents c2a797a + 34fa295 commit c3e0a3a

File tree

11 files changed

+33
-31
lines changed

11 files changed

+33
-31
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,28 @@ The ruleset takes advantage of existing rules in the [WordPress-Coding-Standards
1313

1414
Go to https://vip.wordpress.com/documentation/phpcs-review-feedback/ to learn about why various things are flagged as errors vs warnings and what the levels mean for us.
1515

16-
# Installation
16+
## Installation
1717

1818

19-
First, make sure you have WPCS v1+ and PHPCS v3+ installed. If you do not, please refer to the [installation instructions for installing PHP CodeSniffer for WordPress.com VIP](https://vip.wordpress.com/documentation/how-to-install-php-code-sniffer-for-wordpress-com-vip/)
19+
First, make sure you have WPCS 1.* and PHPCS v3+ installed. If you do not, please refer to the [installation instructions for installing PHP CodeSniffer for WordPress.com VIP](https://vip.wordpress.com/documentation/how-to-install-php-code-sniffer-for-wordpress-com-vip/). Note that VIPCS does not currently work with the `develop` branch of WPCS.
2020

2121
You will also find additional information at the [WordPress Coding Standards for PHP_CodeSniffer project](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#installation).
2222

2323
Then, clone this repo to your local machine, and add the standard to PHPCodeSniffer by appending the folder you cloned into to the end of the installed paths. e.g.
2424

2525
`phpcs --config-set installed_paths [/path/to/wpcsstandard],[path/to/vipcsstandard],etc`
2626

27-
## Minimal requirements
27+
Alternatively, we recommend the [PHP_CodeSniffer Standards Composer Installer Plugin](https://github.com/Dealerdirect/phpcodesniffer-composer-installer), which handles the registration of all of the installed standards, so there is no need to set the `installed_paths` config value manually, for single or multiple standards.
2828

29-
* [PHPCS v3](https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.3.0)
30-
* [WPCS v1.0.0](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/releases/tag/1.0.0)
29+
### Minimal requirements
3130

32-
# Setup note
31+
* [PHPCS 3+](https://github.com/squizlabs/PHP_CodeSniffer/releases)
32+
* [WPCS 1.*](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/releases)
33+
34+
### Setup note
3335

3436
Should you wish to run both standards (WordPress.com VIP minimum standard & WordPress.com VIP coding standard), you can add both to PHPCS by running the following configuration command:
3537

3638
`phpcs --config-set installed_paths [/path/to/standard],[path/to/standard]`
3739

38-
(note the comma separating each standard)
40+
Note the comma separating each standard.

WordPressVIPMinimum/Sniffs/Classes/RestrictedExtendClassesSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RestrictedExtendClassesSniff extends AbstractClassRestrictionsSniff {
2828
public function getGroups() {
2929
return array(
3030
'wp_cli' => array(
31-
'type' => 'warning',
31+
'type' => 'warning',
3232
'message' => 'We recommend extending `WPCOM_VIP_CLI_Command` instead of `WP_CLI_Command` and using the helper functions available in it (such as `stop_the_insanity()`), see https://vip.wordpress.com/documentation/writing-bin-scripts/ for more information.',
3333
'classes' => array(
3434
'WP_CLI_Command',

WordPressVIPMinimum/Sniffs/Filters/RestrictedHookSniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ class RestrictedHookSniff extends AbstractFunctionParameterSniff {
5454
// WordPress.com: https://lobby.vip.wordpress.com/wordpress-com-documentation/fetching-remote-data/.
5555
// VIP Go: https://vip.wordpress.com/documentation/vip-go/fetching-remote-data/.
5656
'type' => 'Warning',
57-
'msg' => 'Please ensure that the timeout being filtered is not greater than 3s since remote requests require the user to wait for completion before the rest of the page will load. Manual inspection required.',
58-
'code' => 'HighTimeout',
57+
'msg' => 'Please ensure that the timeout being filtered is not greater than 3s since remote requests require the user to wait for completion before the rest of the page will load. Manual inspection required.',
58+
'code' => 'HighTimeout',
5959
],
6060
'http_request_args' => [
6161
// WordPress.com: https://lobby.vip.wordpress.com/wordpress-com-documentation/fetching-remote-data/.
6262
// VIP Go: https://vip.wordpress.com/documentation/vip-go/fetching-remote-data/.
6363
'type' => 'Warning',
64-
'msg' => 'Please ensure that the timeout being filtered is not greater than 3s since remote requests require the user to wait for completion before the rest of the page will load. Manual inspection required.',
65-
'code' => 'HighTimeout',
64+
'msg' => 'Please ensure that the timeout being filtered is not greater than 3s since remote requests require the user to wait for completion before the rest of the page will load. Manual inspection required.',
65+
'code' => 'HighTimeout',
6666
],
6767
];
6868

WordPressVIPMinimum/Sniffs/Functions/StripTagsSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class StripTagsSniff extends AbstractFunctionParameterSniff {
3434
* depending on your needs.
3535
*/
3636
protected $target_functions = [
37-
'strip_tags' => true,
37+
'strip_tags' => true,
3838
];
3939

4040
/**

WordPressVIPMinimum/Sniffs/JS/WindowSniff.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public function register() {
5959
'port' => true,
6060
'password' => true,
6161
],
62-
'name' => true,
63-
'status' => true,
62+
'name' => true,
63+
'status' => true,
6464
];
6565

6666
/**
@@ -90,7 +90,7 @@ public function process( File $phpcsFile, $stackPtr ) {
9090
}
9191

9292
$nextTokenPtr = $phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
93-
$nextToken = $tokens[ $nextTokenPtr ]['code'];
93+
$nextToken = $tokens[ $nextTokenPtr ]['code'];
9494
if ( T_OBJECT_OPERATOR !== $nextToken && T_OPEN_SQUARE_BRACKET !== $nextToken ) {
9595
// No . or [' next, bail.
9696
return;
@@ -109,7 +109,7 @@ public function process( File $phpcsFile, $stackPtr ) {
109109
}
110110

111111
$nextNextNextTokenPtr = $phpcsFile->findNext( array_merge( [ T_CLOSE_SQUARE_BRACKET ], Tokens::$emptyTokens ), ( $nextNextTokenPtr + 1 ), null, true, null, true );
112-
$nextNextNextToken = $tokens[ $nextNextNextTokenPtr ]['code'];
112+
$nextNextNextToken = $tokens[ $nextNextNextTokenPtr ]['code'];
113113

114114
$nextNextNextNextToken = false;
115115
if ( T_OBJECT_OPERATOR === $nextNextNextToken || T_OPEN_SQUARE_BRACKET === $nextNextNextToken ) {
@@ -126,7 +126,7 @@ public function process( File $phpcsFile, $stackPtr ) {
126126
}
127127
}
128128

129-
$windowProperty = 'window.';
129+
$windowProperty = 'window.';
130130
$windowProperty .= $nextNextNextNextToken ? $nextNextToken . '.' . $nextNextNextNextToken : $nextNextToken;
131131

132132
$prevTokenPtr = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true, null, true );

WordPressVIPMinimum/Sniffs/Variables/ServerVariablesSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ class ServerVariablesSniff implements Sniff {
2424
* @var array
2525
*/
2626
public $restrictedVariables = array(
27-
'authVariables' => array(
27+
'authVariables' => array(
2828
'PHP_AUTH_USER' => true,
2929
'PHP_AUTH_PW' => true,
3030
),
31-
'userControlledVariables' => array(
31+
'userControlledVariables' => array(
3232
'HTTP_X_IP_TRAIL' => true,
3333
'HTTP_X_FORWARDED_FOR' => true,
3434
'REMOTE_ADDR' => true,

WordPressVIPMinimum/Tests/Filters/AlwaysReturnUnitTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public function getErrorList() {
3131
*/
3232
public function getWarningList() {
3333
return array(
34-
15 => 1,
35-
49 => 1,
36-
88 => 1,
37-
95 => 1,
34+
15 => 1,
35+
49 => 1,
36+
88 => 1,
37+
95 => 1,
3838
105 => 1,
3939
);
4040
}

WordPressVIPMinimum/Tests/Filters/RestrictedHookUnitTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public function getErrorList() {
3333
*/
3434
public function getWarningList() {
3535
return array(
36-
7 => 1,
37-
8 => 1,
38-
9 => 1,
36+
7 => 1,
37+
8 => 1,
38+
9 => 1,
3939
10 => 1,
4040
11 => 1,
4141
12 => 1,

WordPressVIPMinimum/Tests/Variables/VariableAnalysisUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function getErrorList() {
3232
*/
3333
public function getWarningList() {
3434
return [
35-
5 => 2,
35+
5 => 2,
3636
18 => 2,
3737
];
3838
}

bin/phpcs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
#
1010
# ./bin/phpcs
1111

12-
"$(pwd)/vendor/bin/phpcs" --runtime-set ignore_warnings_on_exit 1
12+
"$(pwd)/vendor/bin/phpcs"

0 commit comments

Comments
 (0)