WPCS 3.0: Fix incompatibilities by using PHPCSUtils#734
Closed
WPCS 3.0: Fix incompatibilities by using PHPCSUtils#734
Conversation
Contributor
Author
|
Tests pass fine locally, so not sure why GitHub Actions is having an issue finding and using PHPCSUtils. Edit: Log shows only phpcsstandards/phpcsutils (1.0.0-alpha3) was installed, not alpha4. |
jrfnl
reviewed
Dec 30, 2022
Collaborator
jrfnl
left a comment
There was a problem hiding this comment.
Reviewed with the exception that I haven't done a detailed review of the last two commits (see below).
Along the same lines as my comment on #733:
- Most of this PR does not depend on PR #732. These changes can be made independently of the WPCS update (and in anticipation thereof).
- The first commit should be adding the PHPCSUtils package as a dependency as the other commits all depend on that package being available (the "Composer: Add PHPCSUtils as required dependency" commit).
- If commit 4 ("Add Sniff::merge_custom_array()") stays, I'd suggest squashing commit 6 ("CS: fix coding standards for merge_custom_array()") into that same commit.
- The last two commits ("CI: Refresh unit tests workflow" and "Disable ruleset test") do not belong with this PR.
I actually had a PR ready for most of those changes too, but got stuck on debugging why the ruleset test wasn't working, which is why I hadn't pulled it yet.
I'd recommend rebasing the PR (without those last two commits) on develop and changing the commit order.
This was referenced Jan 24, 2023
74bd1ea to
db681cc
Compare
db681cc to
4dd0ad7
Compare
Contributor
Author
Done. |
1144faa to
5202918
Compare
VIPCS makes use of PHPCSUtils directly (such as for MessageHelper), so it should be marked as such in the Composer config.
This is more tested than the WPCS Sniff::addMessage().
5202918 to
7ce4c18
Compare
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.
Once #742 has been merged, this can be rebased to allow the workflow tests to run. #742 makes PHPCS 3.7.1 as the minimum version for VIPCS, which is the constraint on PHPCSUtils 1.0.Now rebased.Several methods were removed or moved from the Sniff class in WPCS, so these changes were spotted when running unit tests and getting errors. There are undoubtedly many more opportunities to use PHPCSUtils versions of functions to replace existing VIPCS code to improve the quality of the sniffs, but these are not tackled here.
These changes don't require WPCS 3.0 - we're just making the same types of changes that WPCS 3.0, by using PHPCSUtils as a direct dependency.
Composer: Add PHPCSUtils as required dependency
VIPCS uses PHPCSUtils directly (such as for MessageHelper), so it should be marked as such in the Composer config.
Sniff::strip_quotes(): switch to use the PHPCSUtils version
The original
Sniff::strip_quotes()method was removed for WPCS 3.0.Sniff::find_array_open_close(): switch to use the PHPCSUtils version
The original
Sniff::find_array_open_close()method was removed for WPCS 3.0.Sniff::get_function_call_parameter(): switch to use the PHPCSUtils version
The original
Sniff::get_function_call_parameter()method was removed for WPCS 3.0.Use PHPCSUtils MessageHelper::addMessage
This is more tested than the WPCS
Sniff::addMessage(), and the original was removed.