Skip to content

Commit 75d2fcd

Browse files
authored
Merge pull request #14 from Automattic/feature/phpcs-vip-changes
PHPCS rule changes to account for VIP functions
2 parents da1199f + 568d38f commit 75d2fcd

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"phpcompatibility/phpcompatibility-wp": "*"
99
},
1010
"scripts": {
11-
"lint": "./vendor/bin/phpcs --standard=phpcs.xml"
11+
"lint": "./vendor/bin/phpcs --standard=phpcs.xml -n"
1212
},
1313
"autoload": {
1414
"psr-4": {

phpcs.xml

+44-8
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44

55
<rule ref="WordPress-Extra" />
66
<rule ref="WordPress-Docs" />
7-
<rule ref="WordPress-VIP-Go">
8-
<exclude name="WordPressVIPMinimum.Performance.FetchingRemoteData.FileGetContentsUnknown" />
9-
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.count_user_posts_count_user_posts" />
10-
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.attachment_url_to_postid_attachment_url_to_postid" />
11-
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.url_to_postid_url_to_postid" />
7+
<rule ref="WordPress-VIP-Go" >
8+
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get" />
129
</rule>
1310

1411
<!-- Override some rules from WordPressVIPMinimum that call for VIP functions not available on the Newspack platform. -->
15-
<!--
1612
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.count_user_posts_count_user_posts">
1713
<type>warning</type>
1814
<message>%s is uncached, please use it with caution.</message>
@@ -23,10 +19,48 @@
2319
</rule>
2420
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.url_to_postid_url_to_postid">
2521
<type>warning</type>
26-
<message>%s() is uncached, please use it with caution.</message>
22+
<message>%s() is uncached, please use it with caution.</message>
2723
</rule>
28-
-->
24+
<rule ref="WordPressVIPMinimum.Performance.FetchingRemoteData.FileGetContentsRemoteFile">
25+
<type>warning</type>
26+
<message>%s is uncached, please use it with caution.</message>
27+
</rule>
28+
<rule ref="WordPressVIPMinimum.Performance.OrderByRand.orderby_orderby">
29+
<type>warning</type>
30+
<message>The %s parameter can be slow, please use it with caution.</message>
31+
</rule>
32+
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.custom_role_add_role">
33+
<type>warning</type>
34+
<message>%s is uncached, please use it with caution.</message>
35+
</rule>
36+
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.wp_old_slug_redirect_wp_old_slug_redirect">
37+
<type>warning</type>
38+
<message>%s is uncached, please use it with caution.</message>
39+
</rule>
40+
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_next_post_link">
41+
<type>warning</type>
42+
<message>%s is uncached, please use it with caution.</message>
43+
</rule>
44+
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_next_post">
45+
<type>warning</type>
46+
<message>%s is uncached, please use it with caution.</message>
47+
</rule>
48+
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_previous_post_link">
49+
<type>warning</type>
50+
<message>%s is uncached, please use it with caution.</message>
51+
</rule>
52+
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_previous_post">
53+
<type>warning</type>
54+
<message>%s is uncached, please use it with caution.</message>
55+
</rule>
56+
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_adjacent_post">
57+
<type>warning</type>
58+
<message>%s is uncached, please use it with caution.</message>
59+
</rule>
60+
<!-- end of overrides -->
61+
2962

63+
<!-- Standard WordPress sniffs -->
3064
<rule ref="WordPress">
3165
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
3266
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />
@@ -40,6 +74,8 @@
4074
<!-- Allow for PSR-4 file names-->
4175
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
4276
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
77+
<!-- Format inline comments how ever you want -->
78+
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
4379
</rule>
4480

4581
<rule ref="PHPCompatibilityWP"/>

0 commit comments

Comments
 (0)