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 v38 #21523

Merged
merged 10 commits into from
Oct 25, 2021
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
2 changes: 2 additions & 0 deletions .phpcs.config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<exclude-pattern>/vendor/*</exclude-pattern>

<!-- Ignore WordPress and such checked out for Docker -->
<exclude-pattern>/tools/docker/data/*</exclude-pattern>
<exclude-pattern>/tools/docker/mu-plugins/0-sandbox.php</exclude-pattern>
<exclude-pattern>/tools/docker/wordpress-develop/*</exclude-pattern>
<exclude-pattern>/tools/docker/wordpress/*</exclude-pattern>
Expand All @@ -33,6 +34,7 @@
<!-- Ignore built files -->
<exclude-pattern>/projects/packages/connection-ui/build/*</exclude-pattern>
<exclude-pattern>/projects/packages/identity-crisis/build/*</exclude-pattern>
<exclude-pattern>/projects/packages/lazy-images/dist/*</exclude-pattern>
<exclude-pattern>/projects/plugins/backup/build/*</exclude-pattern>
<exclude-pattern>/projects/plugins/jetpack/_inc/blocks/*</exclude-pattern>
<exclude-pattern>/projects/plugins/jetpack/_inc/build/*</exclude-pattern>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"issues": "https://github.com/Automattic/jetpack/issues"
},
"require-dev": {
"automattic/jetpack-codesniffer": "2.2.x-dev",
"automattic/jetpack-codesniffer": "2.3.x-dev",
"dealerdirect/phpcodesniffer-composer-installer": "0.7.1",
"php-parallel-lint/php-parallel-lint": "1.3.1",
"sirbrillig/phpcs-changed": "2.8.1"
Expand Down
115 changes: 24 additions & 91 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Updated mediawiki/mediawiki-codesniffer to v38.
4 changes: 2 additions & 2 deletions projects/packages/codesniffer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "GPL-2.0-or-later",
"require": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"mediawiki/mediawiki-codesniffer": "^37.0",
"mediawiki/mediawiki-codesniffer": "^38.0",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"sirbrillig/phpcs-variable-analysis": "^2.10",
"wp-coding-standards/wpcs": "^2.3"
Expand Down Expand Up @@ -52,7 +52,7 @@
"link-template": "https://github.com/Automattic/jetpack-codesniffer/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-master": "2.2.x-dev"
"dev-master": "2.3.x-dev"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class Dummy_Test extends TestCase {
$this->assertSame( '123.45', $u->var );

// MediaWiki.PHPUnit.AssertionOrder.
$this->assertEquals( $u->var, 1 );
$this->assertSame( $u->var, 1 );
$this->assertSame( 1, $u->var );
$this->assertSame( 1, $u->var );

// MediaWiki.PHPUnit.SpecificAssertions.
$this->assertArrayHasKey( 'foo', $u->var );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
30 | WARNING | [x] assertEquals accepts many non-numeric values, please use strict alternatives like assertSame (MediaWiki.PHPUnit.AssertEquals.Float)
31 | WARNING | [x] assertEquals accepts many non-string values, please use strict alternatives like assertSame (MediaWiki.PHPUnit.AssertEquals.FalsyString)
32 | WARNING | [x] assertEquals accepts many non-string values, please use strict alternatives like assertSame (MediaWiki.PHPUnit.AssertEquals.NumericString)
35 | WARNING | [x] The expected value goes before the actual value in assertions (MediaWiki.PHPUnit.AssertionOrder.WrongOrder)
36 | WARNING | [x] The expected value goes before the actual value in assertions (MediaWiki.PHPUnit.AssertionOrder.WrongOrder)
39 | WARNING | [x] assertArrayHasKey should be used instead of manually using assertTrue with the result of array_key_exists (MediaWiki.PHPUnit.SpecificAssertions.assertArrayHasKey)
40 | WARNING | [x] assertArrayNotHasKey should be used instead of manually using assertFalse with the result of array_key_exists (MediaWiki.PHPUnit.SpecificAssertions.assertArrayNotHasKey)
41 | WARNING | [x] assertContains should be used instead of manually using assertTrue with the result of in_array (MediaWiki.PHPUnit.SpecificAssertions.assertContains)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ public function encrypt_string_for_wpcom( $data ) {

// openssl_free_key was deprecated as no longer needed in PHP 8.0+. Can remove when PHP 8.0 is our minimum. (lol).
if ( PHP_VERSION_ID < 80000 ) {
openssl_free_key( $public_key ); // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.openssl_free_keyDeprecated
openssl_free_key( $public_key ); // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.openssl_free_keyDeprecated, Generic.PHP.DeprecatedFunctions.Deprecated
}

return $return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Fix some new phpcs sniffs in tests.


Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function test_get_track_data_feed_error() {

$error = $podcast_helper->get_track_data( 'invalid_id' );
$this->assertWPError( $error );
$this->assertSame( $error->get_error_code(), 'feed_error' );
$this->assertSame( $error->get_error_message(), 'Feed error.' );
$this->assertSame( 'feed_error', $error->get_error_code() );
$this->assertSame( 'Feed error.', $error->get_error_message() );
}

/**
Expand Down Expand Up @@ -90,8 +90,8 @@ public function test_get_track_data_find_episode() {
// Can't find an episode.
$error = $podcast_helper->get_track_data( 'invalid_id' );
$this->assertWPError( $error );
$this->assertSame( $error->get_error_code(), 'no_track' );
$this->assertSame( $error->get_error_message(), 'The track was not found.' );
$this->assertSame( 'no_track', $error->get_error_code() );
$this->assertSame( 'The track was not found.', $error->get_error_message() );

// Success.
$episode = $podcast_helper->get_track_data( 1 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function test_registered_block_is_not_available() {
Jetpack_Gutenberg::set_extension_unavailable( 'jetpack/banana', 'bar' );
$availability = Jetpack_Gutenberg::get_availability();
$this->assertFalse( $availability['banana']['available'], 'banana is available!' );
$this->assertEquals( $availability['banana']['unavailable_reason'], 'bar', 'unavailable_reason is not "bar"' );
$this->assertEquals( 'bar', $availability['banana']['unavailable_reason'], 'unavailable_reason is not "bar"' );
}

function test_registered_block_is_not_available_when_not_defined_in_whitelist() {
Expand All @@ -113,7 +113,7 @@ function test_block_is_not_available_when_not_registered_returns_missing_module(

// 'unavailable_reason' should be 'missing_module' if the block wasn't registered
$this->assertFalse( $availability['grape']['available'], 'Availability is not false exists' );
$this->assertEquals( $availability['grape']['unavailable_reason'], 'missing_module', 'unavailable_reason is not "missing_module"' );
$this->assertEquals( 'missing_module', $availability['grape']['unavailable_reason'], 'unavailable_reason is not "missing_module"' );
}

// Plugins
Expand All @@ -127,7 +127,7 @@ function test_registered_plugin_is_not_available() {
Jetpack_Gutenberg::set_extension_unavailable( 'jetpack/potato', 'bar' );
$availability = Jetpack_Gutenberg::get_availability();
$this->assertFalse( $availability['potato']['available'], 'potato is available!' );
$this->assertEquals( $availability['potato']['unavailable_reason'], 'bar', 'unavailable_reason is not "bar"' );
$this->assertEquals( 'bar', $availability['potato']['unavailable_reason'], 'unavailable_reason is not "bar"' );
}

function test_registered_plugin_is_not_available_when_not_defined_in_whitelist() {
Expand All @@ -142,7 +142,7 @@ function test_plugin_is_not_available_when_not_registered_returns_missing_module

// 'unavailable_reason' should be 'missing_module' if the block wasn't registered
$this->assertFalse( $availability['tomato']['available'], 'Availability is not false exists' );
$this->assertEquals( $availability['tomato']['unavailable_reason'], 'missing_module', 'unavailable_reason is not "missing_module"' );
$this->assertEquals( 'missing_module', $availability['tomato']['unavailable_reason'], 'unavailable_reason is not "missing_module"' );
}

function test_get_available_extensions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function test_jetpack_client_server_deactivate_plugin() {

$return_value = $client_server->deactivate_plugin( 'herp', 'derp' );

$this->assertEquals( $return_value, 0 );
$this->assertSame( 0, $return_value );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function test_mediaextractor_extract_images_from_content_return_correct_i
$this->assertArrayHasKey( 'image', $image_struct );
$this->assertCount( 1, $image_struct[ 'image' ] );
$this->assertEquals( $image_struct[ 'image' ][ 0 ][ 'url' ], $img_name );
$this->assertEquals( $image_struct[ 'has' ][ 'image' ], 1 );
$this->assertSame( 1, $image_struct['has']['image'] );
}

/**
Expand Down
Loading