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

Composer/PHPCS: update to YoastCS 3.0.0 #155

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Dec 15, 2023

YoastCS 3.0.0 has been released and is based on WordPressCS 3.0.0.

This commit makes the necessary updates for that:

  • Composer: update the requirements.
  • PHPCS ruleset:
    • Update a few sniff/property names for new names in WordPressCS 3.0.
    • Exclude code modernization sniffs which can't be applied to this package yet.
    • Enforce strict PSR-4 for the tests.
    • Remove a few exclusions which are no longer needed.
    • Add a few selective exclusions for specific situations.
  • GHA CS workflow:
    • Run the CS check on the latest PHP version.
      No need to run on PHP 7.4 any more as the deprecations previously encountered were all fixed.
    • Change the CS check from a "normal" PHPCS run to a run using the Thresholds report and only reporting on issues found in files changed in the branch.
      There are currently 8 (documentation) issues which still need to be fixed, so hopefully, the threshold can go back to 0 soon.
  • Add one selective ignore annotation for a class name containing an acronym.
  • Make one more minor CS fix (@return void).

While YoastCS 3.0.0 contains lots of goodies, it also has a downside: a minimum PHP requirement of PHP 7.2, which conflicts with the minimum supported PHP version of this package.

This causes two issues:

  1. A plain composer install will no longer work on PHP < 7.2.
    This means the YoastCS package will need to be removed for the CI test workflow.
  2. As the (Parallel) linting packages are "inherited" from YoastCS, removing YoastCS would break the linting command in CI, so we need to require-dev the Parallel Lint packages in WHIP itself to allow the workflow to continue to work.

With those two work-arounds in place, everything should work again.

Refs:

YoastCS 3.0.0 has been released and is based on WordPressCS 3.0.0.

This commit makes the necessary updates for that:
* Composer: update the requirements.
* PHPCS ruleset:
    - Update a few sniff/property names for new names in WordPressCS 3.0.
    - Exclude code modernization sniffs which can't be applied to this package yet.
    - Enforce strict PSR-4 for the tests.
    - Remove a few exclusions which are no longer needed.
    - Add a few selective exclusions for specific situations.
* GHA CS workflow:
    - Run the CS check on the latest PHP version.
        No need to run on PHP 7.4 any more as the deprecations previously encountered were all fixed.
    - Change the CS check from a "normal" PHPCS run to a run using the Thresholds report and only reporting on issues found in files changed in the branch.
        There are currently 8 (documentation) issues which still need to be fixed, so hopefully, the threshold can go back to 0 soon.
* Add one selective ignore annotation for a class name containing an acronym.
* Make one more minor CS fix (`@return void`).

While YoastCS 3.0.0 contains lots of goodies, it also has a downside: a minimum PHP requirement of PHP 7.2, which conflicts with the minimum supported PHP version of this package.

This causes two issues:
1. A plain `composer install` will no longer work on PHP < 7.2.
    This means the YoastCS package will need to be removed for the CI test workflow.
2. As the (Parallel) linting packages are "inherited" from YoastCS, removing YoastCS would break the linting command in CI, so we need to `require-dev` the Parallel Lint packages in WHIP itself to allow the workflow to continue to work.

With those two work-arounds in place, everything should work again.

Refs:
* https://github.com/Yoast/yoastcs/releases/tag/3.0.0
* https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/3.0.0
@jrfnl jrfnl added this to the 2.0 milestone Dec 15, 2023
@coveralls
Copy link

Pull Request Test Coverage Report for Build 7216525553

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 28.713%

Totals Coverage Status
Change from base Build 7216147027: 0.0%
Covered Lines: 87
Relevant Lines: 303

💛 - Coveralls

@jrfnl jrfnl merged commit 71a47ac into main Dec 15, 2023
17 checks passed
@jrfnl jrfnl deleted the JRF/CS/update-phpcs-ruleset-yoastcs-3.0.0 branch December 15, 2023 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants