From 21d01536e41f7a8762afc54755681e4a01d73eb1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 22 Aug 2023 17:15:30 +0200 Subject: [PATCH] Compatibility/Zoninator: remove the sniff * Remove the sniff. * Remove the related test in the `WordPressVIPMinimum/ruleset-test.inc` file. * Remove the related test in the `WordPress-VIP-Go/ruleset-test.inc` file. --- WordPress-VIP-Go/ruleset-test.inc | 4 +- WordPress-VIP-Go/ruleset-test.php | 1 - .../Sniffs/Compatibility/ZoninatorSniff.php | 90 ------------------- .../Tests/Compatibility/ZoninatorUnitTest.inc | 13 --- .../Tests/Compatibility/ZoninatorUnitTest.php | 43 --------- WordPressVIPMinimum/ruleset-test.inc | 4 +- WordPressVIPMinimum/ruleset-test.php | 1 - 7 files changed, 4 insertions(+), 152 deletions(-) delete mode 100644 WordPressVIPMinimum/Sniffs/Compatibility/ZoninatorSniff.php delete mode 100644 WordPressVIPMinimum/Tests/Compatibility/ZoninatorUnitTest.inc delete mode 100644 WordPressVIPMinimum/Tests/Compatibility/ZoninatorUnitTest.php diff --git a/WordPress-VIP-Go/ruleset-test.inc b/WordPress-VIP-Go/ruleset-test.inc index a5c9f6e5..f9f64919 100644 --- a/WordPress-VIP-Go/ruleset-test.inc +++ b/WordPress-VIP-Go/ruleset-test.inc @@ -322,8 +322,8 @@ class MyWidget extends WP_Widget { class BadTestClass extends WP_CLI_Command { // Warning. } -// WordPressVIPMinimum.Compatibility.ZoninatorSniff -wpcom_vip_load_plugin( 'zoninator', 'plugins', '0.8' ); // Warning. + + // WordPressVIPMinimum.Constants.ConstantString define( WPCOM_VIP ); // Error. diff --git a/WordPress-VIP-Go/ruleset-test.php b/WordPress-VIP-Go/ruleset-test.php index 694ee5fa..6f37a66a 100644 --- a/WordPress-VIP-Go/ruleset-test.php +++ b/WordPress-VIP-Go/ruleset-test.php @@ -196,7 +196,6 @@ 269 => 1, 273 => 1, 322 => 1, - 326 => 1, 332 => 1, 392 => 1, 394 => 1, diff --git a/WordPressVIPMinimum/Sniffs/Compatibility/ZoninatorSniff.php b/WordPressVIPMinimum/Sniffs/Compatibility/ZoninatorSniff.php deleted file mode 100644 index b773c79b..00000000 --- a/WordPressVIPMinimum/Sniffs/Compatibility/ZoninatorSniff.php +++ /dev/null @@ -1,90 +0,0 @@ -tokens[ $stackPtr ]['content'] !== 'wpcom_vip_load_plugin' ) { - return; - } - - $openBracket = $this->phpcsFile->findNext( Tokens::$emptyTokens, $stackPtr + 1, null, true ); - - if ( $this->tokens[ $openBracket ]['code'] !== T_OPEN_PARENTHESIS ) { - // Not a function call. - return; - } - - $plugin_name = $this->phpcsFile->findNext( Tokens::$emptyTokens, $openBracket + 1, null, true ); - - if ( $this->remove_wrapping_quotation_marks( $this->tokens[ $plugin_name ]['content'] ) !== 'zoninator' ) { - return; - } - - $comma = $this->phpcsFile->findNext( Tokens::$emptyTokens, $plugin_name + 1, null, true ); - - if ( ! $comma || $this->tokens[ $comma ]['code'] !== 'PHPCS_T_COMMA' ) { - // We are loading the default version. - return; - } - - $folder = $this->phpcsFile->findNext( Tokens::$emptyTokens, $comma + 1, null, true ); - - $comma = $this->phpcsFile->findNext( Tokens::$emptyTokens, $folder + 1, null, true ); - - if ( ! $comma || $this->tokens[ $comma ]['code'] !== 'PHPCS_T_COMMA' ) { - // We are loading the default version. - return; - } - - $version = $this->phpcsFile->findNext( Tokens::$emptyTokens, $comma + 1, null, true ); - $version = $this->remove_wrapping_quotation_marks( $this->tokens[ $version ]['content'] ); - - if ( version_compare( $version, '0.8', '>=' ) === true ) { - $message = 'Zoninator of version >= v0.8 requires WordPress core REST API. Please, make sure the `wpcom_vip_load_wp_rest_api()` is being called on all sites loading this file.'; - $this->phpcsFile->addWarning( $message, $stackPtr, 'RequiresRESTAPI' ); - } - } - - /** - * Removes the quotation marks around T_CONSTANT_ENCAPSED_STRING. - * - * @param string $text_string T_CONSTANT_ENCAPSED_STRING containing wrapping quotation marks. - * - * @return string String w/o wrapping quotation marks. - */ - public function remove_wrapping_quotation_marks( $text_string ) { - return trim( str_replace( '"', "'", $text_string ), "'" ); - } -} diff --git a/WordPressVIPMinimum/Tests/Compatibility/ZoninatorUnitTest.inc b/WordPressVIPMinimum/Tests/Compatibility/ZoninatorUnitTest.inc deleted file mode 100644 index f183fd2e..00000000 --- a/WordPressVIPMinimum/Tests/Compatibility/ZoninatorUnitTest.inc +++ /dev/null @@ -1,13 +0,0 @@ - => - */ - public function getErrorList() { - return []; - } - - /** - * Returns the lines where warnings should occur. - * - * @return array => - */ - public function getWarningList() { - return [ - 3 => 1, - 4 => 1, - 5 => 1, - 6 => 1, - ]; - } -} diff --git a/WordPressVIPMinimum/ruleset-test.inc b/WordPressVIPMinimum/ruleset-test.inc index 38617dd0..aaef9969 100644 --- a/WordPressVIPMinimum/ruleset-test.inc +++ b/WordPressVIPMinimum/ruleset-test.inc @@ -278,8 +278,8 @@ class MyWidget extends WP_Widget { // WordPressVIPMinimum.Classes.RestrictedExtendClasses class BadTestClass extends WP_CLI_Command { } // Warning. -// WordPressVIPMinimum.Compatibility.ZoninatorSniff -wpcom_vip_load_plugin( 'zoninator', 'plugins', '0.8' ); // Warning. + + // WordPressVIPMinimum.Constants.ConstantString define( WPCOM_VIP ); // Error. diff --git a/WordPressVIPMinimum/ruleset-test.php b/WordPressVIPMinimum/ruleset-test.php index 58e54c38..0972e481 100644 --- a/WordPressVIPMinimum/ruleset-test.php +++ b/WordPressVIPMinimum/ruleset-test.php @@ -248,7 +248,6 @@ 256 => 1, 264 => 2, 279 => 1, - 282 => 1, 288 => 1, 293 => 1, 294 => 1,