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

Update to WPCS 3.0.0 #175

Closed
40 of 42 tasks
danielbachhuber opened this issue Aug 27, 2023 · 8 comments
Closed
40 of 42 tasks

Update to WPCS 3.0.0 #175

danielbachhuber opened this issue Aug 27, 2023 · 8 comments
Assignees
Milestone

Comments

@danielbachhuber
Copy link
Member

danielbachhuber commented Aug 27, 2023

WPCS 3.0.0 was recently released. We should update WP-CLI to use it!

https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-3.0.0-for-Developers-of-external-standards

  • wp-cli/automated-tests
  • wp-cli/admin-command
  • wp-cli/cache-command
  • wp-cli/checksum-command
  • wp-cli/config-command
  • wp-cli/core-command
  • wp-cli/cron-command
  • wp-cli/db-command
  • wp-cli/dist-archive-command
  • wp-cli/doctor-command
  • wp-cli/embed-command
  • wp-cli/entity-command
  • wp-cli/eval-command
  • wp-cli/export-command
  • wp-cli/extension-command
  • wp-cli/find-command
  • wp-cli/i18n-command
  • wp-cli/import-command
  • wp-cli/language-command
  • wp-cli/maintenance-mode-command
  • wp-cli/media-command
  • wp-cli/package-command
  • wp-cli/php-cli-tools
  • wp-cli/profile-command
  • wp-cli/restful
  • wp-cli/rewrite-command
  • wp-cli/role-command
  • wp-cli/scaffold-command
  • wp-cli/scaffold-package-command
  • wp-cli/search-replace-command
  • wp-cli/server-command
  • wp-cli/shell-command
  • wp-cli/snapshot-command
  • wp-cli/super-admin-command
  • wp-cli/widget-command
  • wp-cli/wp-cli
  • wp-cli/wp-cli-bundle
  • wp-cli/wp-cli-dev
  • wp-cli/wp-cli-tests
  • wp-cli/wp-cli.github.com
  • wp-cli/wp-config-transformer
  • wp-cli/wp-super-cache-cli

Done is:

  • This repository is updated to WPCS 3.0.0.
  • All of our repositories are updated to the latest version of this test package and passing.
@swissspidy
Copy link
Member

swissspidy commented Aug 30, 2023

This can be run from the wp-cli-dev repo to quickly assess all packages:

./foreach-bundle "composer require --quiet --dev wp-cli/wp-cli-tests:^4"
./foreach-bundle "composer phpcs"

This way we can identify additional things we might want to add to the default PHPCS config, like for example https://github.com/wp-cli/wp-cli-tests/pull/176/files#r1310157136

At first glance it appears that most of the errors can be auto-fixed, reducing the amount of manual work involved with updating.

Edit: looks like you already tagged a new release; so I updated the command accordingly.

@danielbachhuber
Copy link
Member Author

I'm getting an odd warning with phpcbf...

$ composer phpcbf
> run-phpcbf-cleanup

Deprecated: Creation of dynamic property WordPressCS\WordPress\Sniffs\PHP\NoSilencedErrorsSniff::$use_default_whitelist is deprecated in /Users/danielbachhuber/Desktop/admin-command/vendor/squizlabs/php_codesniffer/src/Ruleset.php on line 1331
. 1 / 1 (100%)

Edit: looks like you already tagged a new release; so I updated the command accordingly.

Yeah, I had to tag in order to start updating the dependencies.

This way we can identify additional things we might want to add to the default PHPCS config, like for example https://github.com/wp-cli/wp-cli-tests/pull/176/files#r1310157136

Want to submit a PR for that?

@swissspidy
Copy link
Member

I'm getting an odd warning with phpcbf...

You need to renameuse_default_whitelist to usePHPFunctionsList here:

<rule ref="WordPress.PHP.NoSilencedErrors">
<properties>
<property name="use_default_whitelist" value="true"/>
</properties>
</rule>

Want to submit a PR for that?

I think we can do all of these ruleset updates in a single PR

@danielbachhuber
Copy link
Member Author

I think we can do all of these ruleset updates in a single PR

@swissspidy Sure... are you doing that?

@swissspidy
Copy link
Member

Started a PR here: #177

@schlessera
Copy link
Member

schlessera commented Aug 30, 2023

This can be run from the wp-cli-dev repo to quickly assess all packages [...]

I also use that script for doing things like this in a case like the above (built from memory and untested):

./foreach-bundle "git checkout -b fix/wpcs-3.0-issues"
./foreach-bundle "composer require --quiet --dev wp-cli/wp-cli-tests:^4 -W"
./foreach-bundle "git add composer.*"
./foreach-bundle "git commit -m 'Update to WPCS v3'"
./foreach-bundle "vendor/bin/phpcbf"
./foreach-bundle "git add --all"
./foreach-bundle "git commit -m 'Fix all autofixable CS issues'"
./foreach-bundle "hub pull-request -m 'Update to WPCS v3' -l 'scope:testing' -m 'Auto-generated PR that updates WPCS to the latest v3 and then runs PHPCBF to fix all automatically fixable issues.'"

This will create a pull request in each bundle repository. Those that pass their tests can be merged right away, the others will be starting points for additional commits to fix any remaining issues.

This has been the most scalable way for working on bundle-wide changes for me.

@schlessera
Copy link
Member

I can run the above (and adapt as needed to create all initial PRs now. Let me do those, and then we can see what else might still need fixing.

@danielbachhuber
Copy link
Member Author

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants