Repository navigation
Add PHPCS rulesets and restore the code-standards deploy gate - #1245
Merged
Merged
Conversation
- Add .phpcs.xml (based on publishpress-future) and .phpcs-plugin-review.xml (needed by the second, WordPress.org plugin-review pass of lint:phpcs). - Exclude the three naming sniffs until a major version: Pro and third-party code use those class and method names. - Exclude the 31 phpcbf-fixable formatting codes for now, with a TODO for a phpcbf pass after 2.30. - Add explicit public visibility to class constants. - Review every nonce-verification finding: annotate read-only uses, and in save_global_checklist() verify the nonce before reading the form. - Use wp_parse_url(), wp_json_encode(), get_stylesheet_directory() and get_template_directory(); annotate the remaining intentional findings. - Run the code-standards workflow on pull requests and put needs: [code-check] back on the WordPress.org deploy job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI creates .cache/wp_test inside the repository, and both lint:phpcs passes scanned its mu-plugin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1207
Makes
composer lint:phpcspass, so the code-standards gate can block the WordPress.org deploy again.Changes
.phpcs.xml: based on publishpress-future's ruleset.PSR1.Methods.CamelCapsMethodName,Squiz.Classes.ValidClassName,PSR1.Classes.ClassDeclaration.MissingNamespace). The comment says they wait for a major version, because Pro and third-party code use those class and method names.vendor,lib/vendor,dist,node_modules,testsand similar folders are excluded, plus.cache, which dev-workspace creates inside the repo in CI (itswp_testmu-plugin made the first CI run fail)..phpcs-plugin-review.xml:lint:phpcsin dev-workspace 1.7.0 runs a second pass with the WordPress.org plugin-review (Plugin Check) rules. Without this file that pass fails with "You must supply at least one file". It's modelled on Future's file.public. Requires PHP is 7.2.5, and Pro only overrides these constants as implicit-publicconst, so nothing breaks.parse_url()→wp_parse_url()json_encode()→wp_json_encode()(only used to build cache keys; the output is the same)STYLESHEETPATH/TEMPLATEPATH→get_stylesheet_directory()/get_template_directory()wp_unslash()isset()guard on$_POST['requirement']in the OpenAI AJAX handler} // comment elseiflayout inOpenai_item::clean_up_content()error_log()in its error handlerstrip_tags()in the word count (switching would change counts)excludein the tag term queryuninstall.phpneeds: [code-check]is back ondeploy-wp-orgindeploy-free.yml.code-standards.ymlnow also runs onpull_request. Before, it only ran when called from another workflow or started by hand, so PRs never got a run..rsync-filters-pre-build).phpcs counts (latest
development, PHP 8.3).phpcs.xmlas is).phpcs.xml)Breakdown of pass 1:
Recommended, 11Missing)composer check:php,composer lint:phpandcomposer lint:phpcspass locally on PHP 8.3.Nonce findings (all 64 reviewed)
No real security issue was found. Every path that changes state already checks both a nonce and a capability: settings save, global checklist save, the post meta box save, and the AJAX handlers. No new issues were opened.
checklists.phpsave_global_checklist()(1 Missing)$_POSTto see whether the form was sent, then checked the nonce. Nothing was saved without a valid nonce andmanage_checklists.Custom_item::filter_settings_validate(),permissions.phpvalidateRequirementSettings()(2 Missing)$_POSTfrom thepublishpress_checklists_validate_requirement_settingsfilter, which only runs insidesave_global_checklist()phpcs:ignore, citing the nonce and capability checks done thereModule::isWhitelistedSettingsView()(7 Recommended)page/moduleto known slugsphpcs:disable/enable, read-only routingModule::printDefaultHeader(),settings.phpoptions_page_controller()(19 Recommended, 8 Missing)module/message/errorargs pick a tab and a notice from a fixed list, escaped on outputphpcs:disable/enable, read-only displayUtil::getCurrentPostType()(5)post/post_typeargs tell which post type the screen is forphpcs:disable/enable, read-onlyLegacyPluginandchecklists.phpClassic Editor checks (4)classic-editor/classic-editor__forgetargsphpcs:ignore, read-only editor detectionchecklists.php/settings.php(10)pagearg decides which assets loadphpcs:ignore, read-onlysettings.php(4)post_typearg decides whether to hide a Quick Edit fieldphpcs:ignore, read-onlyhelper_print_error_or_description()(2)phpcs:disable/enable; also added the missingwp_unslash()successflag (2)phpcs:ignore, read-onlyFormatting: excluded for now, no phpcbf pass
The 240 remaining formatting findings are all auto-fixable, but
phpcbfwould rewrite 61 files right before the 2.30 release. Instead, the 31 exact sniff codes are excluded in.phpcs.xmlunder aTODO: phpcbf pass after 2.30comment. This keeps the PR to annotations, constant visibility and a few one-line changes. The trade-off is that new formatting slips in those 31 codes won't be caught until the phpcbf pass is done.Deferred
PPCH_Reviews,Base_counter,Meta_Description::init_language) belong in a major version, with a deprecation path for Pro and third-party code..phpcs.xmlas part of it.Testing
Smoke-tested on a fresh SandyWP sandbox (latest WordPress, PHP 8.3, Classic Editor plugin):
stdClassobject.The sandbox has been deleted.
🤖 Generated with Claude Code