Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPCS rule changes to account for VIP functions #14

Merged
merged 4 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"phpcompatibility/phpcompatibility-wp": "*"
},
"scripts": {
"lint": "./vendor/bin/phpcs --standard=phpcs.xml"
"lint": "./vendor/bin/phpcs --standard=phpcs.xml -n"
},
"autoload": {
"psr-4": {
Expand Down
52 changes: 44 additions & 8 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@

<rule ref="WordPress-Extra" />
<rule ref="WordPress-Docs" />
<rule ref="WordPress-VIP-Go">
<exclude name="WordPressVIPMinimum.Performance.FetchingRemoteData.FileGetContentsUnknown" />
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.count_user_posts_count_user_posts" />
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.attachment_url_to_postid_attachment_url_to_postid" />
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.url_to_postid_url_to_postid" />
<rule ref="WordPress-VIP-Go" >
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get" />
</rule>

<!-- Override some rules from WordPressVIPMinimum that call for VIP functions not available on the Newspack platform. -->
<!--
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.count_user_posts_count_user_posts">
<type>warning</type>
<message>%s is uncached, please use it with caution.</message>
Expand All @@ -23,10 +19,48 @@
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.url_to_postid_url_to_postid">
<type>warning</type>
<message>%s() is uncached, please use it with caution.</message>
<message>%s() is uncached, please use it with caution.</message>
</rule>
-->
<rule ref="WordPressVIPMinimum.Performance.FetchingRemoteData.FileGetContentsRemoteFile">
<type>warning</type>
<message>%s is uncached, please use it with caution.</message>
</rule>
<rule ref="WordPressVIPMinimum.Performance.OrderByRand.orderby_orderby">
<type>warning</type>
<message>The %s parameter can be slow, please use it with caution.</message>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.custom_role_add_role">
<type>warning</type>
<message>%s is uncached, please use it with caution.</message>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.wp_old_slug_redirect_wp_old_slug_redirect">
<type>warning</type>
<message>%s is uncached, please use it with caution.</message>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_next_post_link">
<type>warning</type>
<message>%s is uncached, please use it with caution.</message>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_next_post">
<type>warning</type>
<message>%s is uncached, please use it with caution.</message>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_previous_post_link">
<type>warning</type>
<message>%s is uncached, please use it with caution.</message>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_previous_post">
<type>warning</type>
<message>%s is uncached, please use it with caution.</message>
</rule>
<rule ref="WordPressVIPMinimum.Functions.RestrictedFunctions.get_adjacent_post_get_adjacent_post">
<type>warning</type>
<message>%s is uncached, please use it with caution.</message>
</rule>
<!-- end of overrides -->


<!-- Standard WordPress sniffs -->
<rule ref="WordPress">
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found" />
Expand All @@ -40,6 +74,8 @@
<!-- Allow for PSR-4 file names-->
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
<exclude name="WordPress.Files.FileName.InvalidClassFileName" />
<!-- Format inline comments how ever you want -->
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
</rule>

<rule ref="PHPCompatibilityWP"/>
Expand Down