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 dependency mediawiki/mediawiki-codesniffer to v44 #39648

Merged
merged 8 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 88 additions & 73 deletions composer.lock

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion projects/packages/codesniffer/Jetpack/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<rule ref="MediaWiki.PHPUnit.AssertionOrder" />
<rule ref="MediaWiki.PHPUnit.MockBoilerplate" />
<rule ref="MediaWiki.PHPUnit.SpecificAssertions" />
<rule ref="MediaWiki.Usage.DoubleNotOperator" />
<rule ref="MediaWiki.Usage.InArrayUsage" />
<rule ref="MediaWiki.Usage.MagicConstantClosure" />
<rule ref="MediaWiki.Usage.NestedFunctions" />
Expand Down Expand Up @@ -122,4 +121,9 @@
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames" />
</rule>

<!-- Needs discussion before we enable this. It doesn't auto-fix, and boolean operator precedence should be pretty basic knowledge. -->
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we had already done so: p1711387975403439-slack-C05Q5HSS013

<rule ref="Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence">
<exclude name="Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence.MissingParentheses" />
</rule>

</ruleset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: changed

Use mediawiki/mediawiki-codesniffer v44.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: removed

`MediaWiki.Usage.DoubleNotOperator` has been removed. `Universal.CodeAnalysis.NoDoubleNegative.FoundDouble`, which serves the same purpose, will be included via the WordPress-Extra ruleset v3.1.0.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Disable new `Generic.CodeAnalysis.RequireExplicitBooleanOperatorPrecedence.MissingParentheses` sniff for now, pending discussion.
2 changes: 1 addition & 1 deletion projects/packages/codesniffer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"require": {
"php": ">=7.4",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"mediawiki/mediawiki-codesniffer": "^43.0",
"mediawiki/mediawiki-codesniffer": "^44.0",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"sirbrillig/phpcs-variable-analysis": "^2.10",
"wp-coding-standards/wpcs": "^3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Dummy_Class {
require_once 'bar.php';
$u->clone = clone $x;

// MediaWiki.Usage.DoubleNotOperator.
// Universal.CodeAnalysis.NoDoubleNegative.FoundDouble (formerly MediaWiki.Usage.DoubleNotOperator).
$u->bool = (bool) $u->bool;

// MediaWiki.Usage.ForbiddenFunctions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
44 | WARNING | [x] require_once keyword must not be used as a function. (MediaWiki.ExtraCharacters.ParenthesesAroundKeyword.ParenthesesAroundKeywords)
44 | ERROR | [ ] Absolute include path must be used. Use `get_template_directory()`, `get_stylesheet_directory()` or `plugin_dir_path()`. (WordPressVIPMinimum.Files.IncludingFile.NotAbsolutePath)
45 | WARNING | [x] clone keyword must not be used as a function. (MediaWiki.ExtraCharacters.ParenthesesAroundKeyword.ParenthesesAroundKeywords)
48 | WARNING | [x] Use (bool) instead of !! (MediaWiki.Usage.DoubleNotOperator.DoubleNotOperator)
48 | ERROR | [x] Double negative detected. Use a (bool) cast instead. Found: ! ! (Universal.CodeAnalysis.NoDoubleNegative.FoundDouble)
51 | WARNING | [x] Use rtrim() instead of chop (MediaWiki.Usage.ForbiddenFunctions.chop)
52 | WARNING | [x] Use mb_strlen() instead of mbstrlen (MediaWiki.Usage.ForbiddenFunctions.mbstrlen)
57 | ERROR | [ ] Found slow in_array( …, array_keys() ), should be array_key_exists() or isset() (MediaWiki.Usage.InArrayUsage.Found)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Dummy_Class {
require_once( 'bar.php' );
$u->clone = clone( $x );

// MediaWiki.Usage.DoubleNotOperator.
// Universal.CodeAnalysis.NoDoubleNegative.FoundDouble (formerly MediaWiki.Usage.DoubleNotOperator).
$u->bool = ! ! $u->bool;

// MediaWiki.Usage.ForbiddenFunctions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fix missing types in phpdoc comments.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct( $assoc_parser_array ) {
* It will then loop over each key that was provided in the constructor
* and pull the value based on that key from the $data array.
*
* @param $value mixed[]
* @param array|object $value
*
* @return array
* @throws Schema_Error - If the $data passed to it is not an associative array.
Expand Down
5 changes: 1 addition & 4 deletions projects/packages/wp-js-data-sync/.phan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@
// PhanImpossibleCondition : 1 occurrence
// PhanPluginSimplifyExpressionBool : 1 occurrence
// PhanRedundantCondition : 1 occurrence
// PhanTypeMismatchProperty : 1 occurrence
// PhanUndeclaredTypeParameter : 1 occurrence
// PhanUnreferencedUseNormal : 1 occurrence

// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'src/class-data-sync-entry-adapter.php' => ['PhanParamTooFew'],
'src/class-ds-utils.php' => ['PhanImpossibleCondition', 'PhanRedundantCondition'],
'src/class-registry.php' => ['PhanUndeclaredTypeParameter'],
'src/contracts/interface-lazy-entry.php' => ['PhanUnreferencedUseNormal'],
'src/endpoints/class-action-endpoint.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchProperty'],
'src/endpoints/class-action-endpoint.php' => ['PhanPluginDuplicateConditionalNullCoalescing'],
'src/endpoints/class-endpoint.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fix missing types in phpdoc comments.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ final class Data_Sync_Entry_Adapter implements Data_Sync_Entry {
* The constructor accepts any entry that subscribes to at least "Entry_Can_Get", but can also
* subscribe to any of the other Entry_Can_* interfaces.
*
* @param $entry Entry_Can_Get - The data sync entry.
* @param $schema Parser - The schema for the data sync entry.
* @param Entry_Can_Get $entry - The data sync entry.
* @param Parser $schema - The schema for the data sync entry.
*/
public function __construct( $entry, $schema ) {
$this->entry = $entry;
Expand Down
23 changes: 12 additions & 11 deletions projects/packages/wp-js-data-sync/src/class-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Automattic\Jetpack\WP_JS_Data_Sync;

use Automattic\Jetpack\Schema\Schema_Parser;
use Automattic\Jetpack\WP_JS_Data_Sync\Contracts\Data_Sync_Entry;
use Automattic\Jetpack\WP_JS_Data_Sync\Endpoints\Action_Endpoint;
use Automattic\Jetpack\WP_JS_Data_Sync\Endpoints\Endpoint;
Expand Down Expand Up @@ -42,7 +43,7 @@ class Registry {
* There can be multiple registries, reference them by namepsace.
* For example "jetpack_boost".
*
* @param $namespace string The namespace for this registry instance.
* @param string $namespace The namespace for this registry instance.
*/
public function __construct( $namespace ) {
$this->namespace = $namespace;
Expand All @@ -51,7 +52,7 @@ public function __construct( $namespace ) {
/**
* Sanitize a key.
*
* @param $key string - Keys should only include alphanumeric characters and underscores.
* @param string $key - Keys should only include alphanumeric characters and underscores.
*
* @return string
* @throws \Exception In debug mode, if the key is invalid.
Expand All @@ -71,7 +72,7 @@ private function sanitize_key( $key ) {
/**
* Sanitize a key for use in a URL.
*
* @param $key - Keys should only include alphanumeric characters and underscores.
* @param string $key - Keys should only include alphanumeric characters and underscores.
*
* @return string
*/
Expand All @@ -82,8 +83,8 @@ private function sanitize_url_key( $key ) {
/**
* Register a new entry and add it to the registry.
*
* @param $key string - The name of the entry. For example `widget_status`.
* @param $entry Data_Sync_Entry
* @param string $key - The name of the entry. For example `widget_status`.
* @param Data_Sync_Entry $entry
*
* @return Data_Sync_Entry
*/
Expand All @@ -103,10 +104,10 @@ public function register( $key, $entry ) {
/**
* Register an action endpoint.
*
* @param string $key The base key for the endpoint.
* @param string $action_name The name of the action.
* @param Schema $request_schema The schema for the action's request body.
* @param mixed $action_class The class handling the action logic.
* @param string $key The base key for the endpoint.
* @param string $action_name The name of the action.
* @param Schema_Parser $request_schema The schema for the action's request body.
* @param mixed $action_class The class handling the action logic.
*/
public function register_action( $key, $action_name, $request_schema, $action_class ) {
// Create and store the action endpoint instance
Expand Down Expand Up @@ -167,7 +168,7 @@ public function all() {
/**
* Get the endpoint for a given key.
*
* @param $key string - The key for the endpoint.
* @param string $key - The key for the endpoint.
*
* @return Endpoint|false
*/
Expand All @@ -181,7 +182,7 @@ public function get_endpoint( $key ) {
/**
* Get the entry for a given key.
*
* @param $key string - The key for the entry.
* @param string $key - The key for the entry.
*
* @return Data_Sync_Entry|false
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class Action_Endpoint {
/**
* This class handles endpoints for DataSync actions.
*
* @param $namespace
* @param $key
* @param $action_name
* @param $request_schema
* @param $action_class
* @param string $namespace
* @param string $key
* @param string $action_name
* @param Schema_Parser $request_schema
* @param Data_Sync_Action $action_class
*/
public function __construct( $namespace, $key, $action_name, $request_schema, $action_class ) {
$this->action_class = $action_class;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed
Comment: Fix missing types in phpdoc comments.

Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public function getDatabase() {
/**
* Get the JetpackCRM table name
*
* @param $name
* @param string $name
* @return string
*/
public function table( $name ) {
Expand All @@ -265,8 +265,8 @@ public function pdo() {
/**
* Load a page from it's core slug
*
* @param $page_slug
* @param string $query
* @param string $page_slug
* @param string $query
*/
public function goToPageViaSlug( $page_slug, $query = '' ) {
$this->amOnAdminPage( 'admin.php?page=' . $this->slugs[ $page_slug ] . $query );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class RunProcess {
/**
* RunProcess constructor.
*
* @param $cmd
* @param string $outputFile
* @param bool $append
* @param string|null $cmd
* @param string $outputFile
* @param bool $append
*/
public function __construct( $cmd, $outputFile = '/dev/null', $append = false ) {
$this->cmd = $cmd;
Expand Down
Loading