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 WPCS to v3.0, and fix all reported Coding Standards issues #53866

Merged
merged 16 commits into from Sep 13, 2023

Conversation

aristath
Copy link
Member

@aristath aristath commented Aug 22, 2023

What?

Updates WPCS to v3.0

Why?

A few days ago v3.0.0 of the WPCS package was released by @jrfnl.
More details about the package and v3.0 can be found on the post on https://make.wordpress.org/core/2023/08/21/wordpresscs-3-0-0-is-now-available/

Updating the package will ensure that Gutenberg is compatible with PHP versions greater than 8.x, and enforces stricter rules for consistency.

How?

  • Updated the package
  • Ran phpcbf to fix some spacing issues and all the "simple" stuff
  • Ran phpcs and manually fixed the remaining issues

Testing Instructions

If automated tests pass we're good.

Testing Instructions for Keyboard

Not required.

@aristath aristath requested a review from jrfnl August 22, 2023 08:51
@github-actions
Copy link

github-actions bot commented Aug 22, 2023

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/block-supports/border.php
❔ lib/block-supports/elements.php
❔ lib/block-supports/layout.php
❔ lib/block-supports/typography.php
❔ lib/blocks.php
❔ lib/class-wp-duotone-gutenberg.php
❔ lib/class-wp-theme-json-data-gutenberg.php
❔ lib/class-wp-theme-json-gutenberg.php
❔ lib/class-wp-theme-json-resolver-gutenberg.php
❔ lib/compat/wordpress-6.3/blocks.php
❔ lib/compat/wordpress-6.3/class-gutenberg-navigation-fallback.php
❔ lib/compat/wordpress-6.3/html-api/class-gutenberg-html-tag-processor-6-3.php
❔ lib/compat/wordpress-6.3/rest-api.php
❔ lib/compat/wordpress-6.3/script-loader.php
❔ lib/compat/wordpress-6.4/fonts/fonts.php
❔ lib/compat/wordpress-6.4/script-loader.php
❔ lib/experimental/block-hooks.php
❔ lib/experimental/blocks.php
❔ lib/experimental/class-wp-rest-customizer-nonces.php
❔ lib/experimental/fonts-api/bc-layer/class-wp-web-fonts.php
❔ lib/experimental/fonts-api/class-wp-fonts.php
❔ lib/experimental/fonts-api/fonts-api.php
❔ lib/experimental/fonts/font-library/class-wp-font-family.php
❔ lib/experimental/interactivity-api/class-wp-directive-context.php
❔ lib/experimental/interactivity-api/class-wp-directive-processor.php
❔ lib/experimental/interactivity-api/class-wp-interactivity-store.php
❔ lib/experimental/interactivity-api/directive-processing.php
❔ lib/experimental/kses.php
❔ lib/experimental/navigation-theme-opt-in.php
❔ phpunit/blocks/render-block-navigation-submenu-test.php
❔ phpunit/blocks/render-block-navigation-test.php
❔ phpunit/blocks/render-comment-template-test.php
❔ phpunit/blocks/render-post-template-test.php
❔ phpunit/class-block-context-test.php
❔ phpunit/class-block-library-navigation-link-test.php
❔ phpunit/class-gutenberg-navigation-fallback-gutenberg-test.php
❔ phpunit/class-gutenberg-rest-navigation-fallback-controller-test.php
❔ phpunit/class-phpunit-environment-setup-test.php
❔ phpunit/class-wp-theme-json-resolver-test.php
❔ phpunit/class-wp-theme-json-test.php
❔ phpunit/experimental/interactivity-api/directive-processing-test.php
❔ phpunit/experimental/interactivity-api/directives/wp-context-test.php
❔ phpunit/l10n-test.php
❔ phpunit/tests/fonts-api/base.php
❔ phpunit/tests/fonts-api/wpFonts/add.php
❔ phpunit/tests/fonts-api/wpFonts/addFontFamily.php
❔ phpunit/tests/fonts-api/wpFonts/doItem.php
❔ phpunit/tests/fonts-api/wpFonts/doItems.php
❔ phpunit/tests/fonts-api/wpFonts/registerProvider.php
❔ phpunit/tests/fonts-api/wpFontsResolver/registerFontsFromThemeJson.php
❔ phpunit/tests/fonts-api/wpRegisterFontProvider.php
❔ phpunit/tests/fonts/font-face/base.php
❔ phpunit/tests/fonts/font-library/wpFontLibrary/getFontCollection.php
❔ phpunit/tests/fonts/font-library/wpRestFontLibraryController/getFontCollection.php
❔ phpunit/tests/fonts/font-library/wpRestFontLibraryController/getFontCollections.php
❔ phpunit/tests/fonts/font-library/wpRestFontLibraryController/installFonts.php
❔ phpunit/tests/fonts/font-library/wpRestFontLibraryController/registerRoutes.php
❔ phpunit/tests/fonts/font-library/wpRestFontLibraryController/uninstallFonts.php

@aristath aristath marked this pull request as ready for review August 22, 2023 09:07
@aristath aristath added the [Type] Enhancement A suggestion for improvement. label Aug 22, 2023
Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @aristath Thanks for setting this up! Looking good. Just left a few remarks inline for you to consider.

composer.json Outdated Show resolved Hide resolved
test/emptytheme/functions.php Show resolved Hide resolved
test/gutenberg-test-themes/behaviors-enabled/index.php Outdated Show resolved Hide resolved
phpcs.xml.dist Outdated Show resolved Hide resolved
phpcs.xml.dist Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Aug 23, 2023

Flaky tests detected in b0b94b3.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6168767791
📝 Reported issues:

@aristath aristath changed the title Update WPCS to v3.0 Update WPCS to v3.0, and fix all reported Coding Standards issues Aug 23, 2023
@github-actions github-actions bot added this to the Gutenberg 16.7 milestone Sep 13, 2023
@dmsnell
Copy link
Contributor

dmsnell commented Sep 14, 2023

@aristath sorry I didn't catch this before it was merged.

for HTML API code this is pulled from Core, so changes need to happen first in Core and then be pulled into Gutenberg. second, the change from a while to a do probably introduced a vulnerability by using values that aren't checked. we should be careful to ensure our style preference changes don't impact the runtime behavior of code.

I'd like to revert the HTML API changes from here if it's okay with you and then work backwards from Core. can you create a patch/Trac ticket in Core to address the issues you have? in the meantime I'd like to revert so that we don't start maintaining two separate copies of this code.

dmsnell added a commit that referenced this pull request Sep 14, 2023
Pulling over work on the HTML API from Core:

 - bug fixes for parsing inside of STYLE, IFRAME, and other RAWTEXT elements.
 - bug fix when document ends in the middle of processing a tag.
 - reverts changes made in #53866 which introduced a bug during a styling refactor
dmsnell added a commit that referenced this pull request Sep 19, 2023
Pulling over work on the HTML API from Core:

 - bug fixes for parsing inside of STYLE, IFRAME, and other RAWTEXT elements.
 - bug fix when document ends in the middle of processing a tag.
 - reverts changes made in #53866 which introduced a bug during a styling refactor
 - stop processing in the HTML Processor when encountering unsupported markup
 - update docblock comments through HTML API
dmsnell added a commit that referenced this pull request Sep 19, 2023
Pulling over work on the HTML API from Core:

 - bug fixes for parsing inside of STYLE, IFRAME, and other RAWTEXT elements.
 - bug fix when document ends in the middle of processing a tag.
 - reverts changes made in #53866 which introduced a bug during a styling refactor
 - stop processing in the HTML Processor when encountering unsupported markup
 - update docblock comments through HTML API
@bph bph added the [Type] Code Quality Issues or PRs that relate to code quality label Sep 19, 2023
@github-actions
Copy link

github-actions bot commented Sep 19, 2023

Warning: Type of PR label error

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Accessibility (a11y), [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core.
  • Labels found: [Type] Automated Testing, [Type] Code Quality.

Read more about Type labels in Gutenberg.

@bph bph added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. and removed [Type] Enhancement A suggestion for improvement. labels Sep 19, 2023
@aristath
Copy link
Member Author

@aristath sorry I didn't catch this before it was merged.

for HTML API code this is pulled from Core, so changes need to happen first in Core and then be pulled into Gutenberg. second, the change from a while to a do probably introduced a vulnerability by using values that aren't checked. we should be careful to ensure our style preference changes don't impact the runtime behavior of code.

I'd like to revert the HTML API changes from here if it's okay with you and then work backwards from Core. can you create a patch/Trac ticket in Core to address the issues you have? in the meantime I'd like to revert so that we don't start maintaining two separate copies of this code.

Of course, we can revert the changes to the HTML API in Gutenberg.
I think that WPCS 3.0 changes were already merged in Core, so this should have already been updated (if there are any commits remaining I'm sure they'll be merged soon).

@dmsnell
Copy link
Contributor

dmsnell commented Sep 19, 2023

I think that WPCS 3.0 changes were already merged in Core, so this should have already been updated (if there are any commits remaining I'm sure they'll be merged soon).

@aristath unfortunately not, and the two repos have different style preferences, so again, unfortunately, we now have divergent code in Core and Gutenberg and it's quite a mess. some of the changed introduced here have been applied to trunk in Core, but they haven't been applied to the 6.3 branch, meaning that when we pull the already-accepted and already-merged code from Core into Gutenberg, the 6.3 compat layer should have styles that WPCS doesn't like while eventually the 6.4 compat layer shouldn't.

currently I'm unable to revert without overriding the CI job because it's rejecting the change on style preferences, which is unfortunate, because it's enforcing that bug 🙃

I've mentioned you on #54481 where I'm trying to sort it all out, but admittedly, it's very confusing.

dmsnell added a commit that referenced this pull request Sep 27, 2023
Pulling over work on the HTML API from Core:

 - bug fix: stop parsing tags inside of STYLE, IFRAME, and other RAWTEXT elements.
 - bug fix: stay on track when document ends in the middle of processing a tag.
 - bug fix: remove all copies of an attribute when duplicates exist on a tag.
 - bug fix: stop processing in the HTML Processor when encountering unsupported markup
 - reverts changes made in #53866 which introduced a bug during a styling refactor.
 - update docblock comments through HTML API.

This patch also excludes the HTML API folders in the compatability
layer from WPCS inspection, since this code is maintained, reviewed,
and accepted into Core and brought back into Gutenberg. Changes to
the code need to be made first in Core and brought over as blessed
backport changes.

Co-authored-by: Ari Stathopoulos <aristath@gmail.com>
Co-authored-by: Bernie Reiter <96308+ockham@users.noreply.github.com>
dmsnell added a commit that referenced this pull request Sep 27, 2023
Pulling over work on the HTML API from Core:

 - bug fix: stop parsing tags inside of STYLE, IFRAME, and other RAWTEXT elements.
 - bug fix: stay on track when document ends in the middle of processing a tag.
 - bug fix: remove all copies of an attribute when duplicates exist on a tag.
 - bug fix: stop processing in the HTML Processor when encountering unsupported markup
 - reverts changes made in #53866 which introduced a bug during a styling refactor.
 - update docblock comments through HTML API.

This patch also excludes the HTML API folders in the compatability
layer from WPCS inspection, since this code is maintained, reviewed,
and accepted into Core and brought back into Gutenberg. Changes to
the code need to be made first in Core and brought over as blessed
backport changes.

Co-authored-by: Ari Stathopoulos <aristath@gmail.com>
Co-authored-by: Bernie Reiter <96308+ockham@users.noreply.github.com>
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Sep 28, 2023
Now that the `block-library` package is updated for WP 6.4, this is no longer necessary.

Related PR from Gutenberg repository:
* [WordPress/gutenberg#53866 #53866 Update WPCS to v3.0, and fix all reported Coding Standards issues]

Follow-up to [56695], [56710].

See #59161.

git-svn-id: https://develop.svn.wordpress.org/trunk@56741 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Sep 28, 2023
Now that the `block-library` package is updated for WP 6.4, this is no longer necessary.

Related PR from Gutenberg repository:
* [WordPress/gutenberg#53866 #53866 Update WPCS to v3.0, and fix all reported Coding Standards issues]

Follow-up to [56695], [56710].

See #59161.
Built from https://develop.svn.wordpress.org/trunk@56741


git-svn-id: http://core.svn.wordpress.org/trunk@56253 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to gilzow/wordpress-performance that referenced this pull request Sep 28, 2023
Now that the `block-library` package is updated for WP 6.4, this is no longer necessary.

Related PR from Gutenberg repository:
* [WordPress/gutenberg#53866 #53866 Update WPCS to v3.0, and fix all reported Coding Standards issues]

Follow-up to [56695], [56710].

See #59161.
Built from https://develop.svn.wordpress.org/trunk@56741


git-svn-id: https://core.svn.wordpress.org/trunk@56253 1a063a9b-81f0-0310-95a4-ce76da25c4cd
anton-vlasenko pushed a commit to anton-vlasenko/wordpress-develop that referenced this pull request Sep 29, 2023
Now that the `block-library` package is updated for WP 6.4, this is no longer necessary.

Related PR from Gutenberg repository:
* [WordPress/gutenberg#53866 #53866 Update WPCS to v3.0, and fix all reported Coding Standards issues]

Follow-up to [56695], [56710].

See #59161.

git-svn-id: https://develop.svn.wordpress.org/trunk@56741 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants