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

3.0: support WordPressCS 3.0 #779

Merged
merged 11 commits into from
Aug 25, 2023
Merged

3.0: support WordPressCS 3.0 #779

merged 11 commits into from
Aug 25, 2023

Commits on Aug 24, 2023

  1. Composer: update WordPressCS + PHPCS dependencies

    WordPressCS 3.0.0 has been released and requires a minimum PHPCS version of 3.7.2.
    
    This commit updates the WordPressCS and PHPCS dependencies and the documentation referring to those, in all the relevant places.
    
    Includes:
    * Removing the DealerDirect plugin from `require` as it comes with WordPressCS 3.0.0 automatically (via PHPCSUtils) and not having the explicit dependency may prevent conflicts with allowed versions in the future.
    * Updating the PHP version on which the CS check for the VIPCS native code is being run. With WPCS 3.0, this check is no longer limited to PHP 7.4.
    * Removing a work-around for WPCS < 3.0 vs PHP 8.0
    * Updating the VIPCS native `.phpcs.xml.dist` ruleset.
    
    Ref: https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/3.0.0
    jrfnl committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    0301892 View commit details
    Browse the repository at this point in the history
  2. WPCS 3.0 | Revert previously applied work-arounds

    These are no longer needed with WPCS 3.0.0.
    
    Ref: 746
    jrfnl committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    d30a303 View commit details
    Browse the repository at this point in the history
  3. Security/EscapingVoidReturnFunctions: switch to using WPCS PrintingFu…

    …nctionsTrait
    
    Note: this does mean that the sniff will now also support a `public` `customPrintingFunctions` property which can be adjusted in a custom ruleset.
    
    Co-authored-by: Gary Jones <gary.jones@automattic.com>
    jrfnl and GaryJones committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    4198a6d View commit details
    Browse the repository at this point in the history
  4. AbstractVariableRestrictionsSniff: use WPCS ContextHelper::is_in_isse…

    …t_or_empty()
    
    Co-authored-by: Gary Jones <gary.jones@automattic.com>
    jrfnl and GaryJones committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    f124466 View commit details
    Browse the repository at this point in the history
  5. AbstractVariableRestrictionsSniff: use WPCS RulesetPropertyHelper::me…

    …rge_custom_array()
    
    Co-authored-by: Gary Jones <gary.jones@automattic.com>
    jrfnl and GaryJones committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    1a8b51c View commit details
    Browse the repository at this point in the history
  6. AbstractArrayAssignmentRestrictions children: adjust for changes in r…

    …eceived `$val`
    
    The `$val` parameter received by the `callback()` method will no longer automatically have been stripped of quotes.
    
    This adjusts the `callback()` methods of the sniff which extend the WPCS `AbstractArrayAssignmentRestrictions` sniff to take this into account.
    jrfnl committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    29920a0 View commit details
    Browse the repository at this point in the history
  7. VIPMinimum ruleset: replace strict comparison sniff

    Includes adding PHPCSExtra to the `composer.json` configuration as that is now a direct dependency of VIPCS as VIPCS now uses one of its sniffs in the ruleset.
    
    Co-authored-by: Gary Jones <gary.jones@automattic.com>
    jrfnl and GaryJones committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    71dbddd View commit details
    Browse the repository at this point in the history
  8. VIPMinimum ruleset: replace assignment-in-condition sniff

    ... which has been split.
    jrfnl committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    6d05fff View commit details
    Browse the repository at this point in the history
  9. VIPMinimum ruleset: update excludes for the WP/AlternativeFunctions s…

    …niff
    
    ... to prevent introducing new duplicate error messages.
    
    Co-authored-by: Gary Jones <gary.jones@automattic.com>
    jrfnl and GaryJones committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    436b0fe View commit details
    Browse the repository at this point in the history
  10. Update ruleset tests: account for new errors from WPCS

    * The `WordPress.Security.ValidatedSanitizedInput` sniff will now also examine `$_SESSION` variables.
        As the test is about another sniff, let's just ignore the notices coming from `WordPress.Security.ValidatedSanitizedInput`.
    jrfnl committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    4094eec View commit details
    Browse the repository at this point in the history
  11. WordPressVIPMinimum RulesetTest: fix it

    To be honest, I'm completely stumped. I can't, for the life of me, think of a reason why the update of the WPCS dependency would suddenly cause all sorts of notices from the `VariableAnalysis` to show, where they previously did not.
    
    * It can't be related to the version update of the `VariableAnalysis` sniff in VIPCS 2.3.4, nor the move of the properties from the Go ruleset to the Minimum ruleset as, in that case, the build for the earlier PR/commit should also have been failing.
    * It can't be related to the VIPCS native `VariableAnalysis` sniff being removed as, in that case, the build for the earlier PR/commit should also have been failing.
    * VA and WPCS currently have two overlapping CS related dependencies.
        - PHP_CodeSniffer itself, but as they both use the same version, that can not be a reason for the change in the results.
        - The Composer plugin, but that shouldn't influence the scan results, other than if a ruleset would not be registered, but if that were the case (for VA), the tests should have been failing before on line 264, which specifically tests the VA standard triggering a notice (and yes, I checked, it did do so correctly before and after).
    * No new parse errors were accidentally introduced into the test files.
    
    As things are, I'm out of ideas of why these warnings are now suddenly showing up, so all I can do is fix them (by selectively silencing the notices from VA).
    
    Note: this is only happening in the Minimum ruleset test as VIPGo silences the `UnusedVariable` notice completely.
    jrfnl committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    36f1684 View commit details
    Browse the repository at this point in the history