Coding Standards: Upgrade WPCS to 1.0.0

WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.



git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2018-08-17 01:50:26 +00:00
parent fed48ba3fe
commit a75d153eee
549 changed files with 9936 additions and 6721 deletions
+14 -8
View File
@@ -40,19 +40,25 @@ class Tests_Admin_includesFile extends WP_UnitTestCase {
$error = download_url( 'test_download_url_non_200' );
$this->assertWPError( $error );
$this->assertEquals( array(
'code' => 418,
'body' => 'This is an unexpected error message from your favorite server.',
), $error->get_error_data() );
$this->assertEquals(
array(
'code' => 418,
'body' => 'This is an unexpected error message from your favorite server.',
),
$error->get_error_data()
);
add_filter( 'download_url_error_max_body_size', array( $this, '__return_5' ) );
$error = download_url( 'test_download_url_non_200' );
$this->assertWPError( $error );
$this->assertEquals( array(
'code' => 418,
'body' => 'This ',
), $error->get_error_data() );
$this->assertEquals(
array(
'code' => 418,
'body' => 'This ',
),
$error->get_error_data()
);
remove_filter( 'download_url_error_max_body_size', array( $this, '__return_5' ) );
remove_filter( 'pre_http_request', array( $this, '_fake_download_url_non_200_response_code' ) );
@@ -81,7 +81,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
array(
'paged' => 1,
'posts_per_page' => 2,
), array(
),
array(
self::$top[1]->ID,
self::$children[1][1]->ID,
)
@@ -96,7 +97,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
array(
'paged' => 2,
'posts_per_page' => 2,
), array(
),
array(
self::$top[1]->ID,
self::$children[1][2]->ID,
self::$children[1][3]->ID,
@@ -113,7 +115,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
'paged' => 1,
'posts_per_page' => 2,
's' => 'Child',
), array(
),
array(
self::$children[1][1]->ID,
self::$children[1][2]->ID,
)
@@ -129,7 +132,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
'paged' => 2,
'posts_per_page' => 2,
's' => 'Top',
), array(
),
array(
self::$top[3]->ID,
self::$top[4]->ID,
)
@@ -145,7 +149,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
array(
'paged' => 6,
'posts_per_page' => 2,
), array(
),
array(
self::$top[3]->ID,
self::$children[3][1]->ID,
self::$grandchildren[3][1][1]->ID,
@@ -163,7 +168,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
array(
'paged' => 7,
'posts_per_page' => 2,
), array(
),
array(
self::$top[3]->ID,
self::$children[3][1]->ID,
self::$grandchildren[3][1][3]->ID,
@@ -187,7 +193,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
$args = array_merge(
array(
'post_type' => 'page',
), $args
),
$args
);
// Mimic the behaviour of `wp_edit_posts_query()`:
+3 -1
View File
@@ -389,7 +389,9 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
wp_set_current_user( self::$admin_id );
$p = self::factory()->attachment->create_object(
'صورة.jpg', 0, array(
'صورة.jpg',
0,
array(
'post_mime_type' => 'image/jpeg',
'post_type' => 'attachment',
'post_title' => 'صورة',
+4 -2
View File
@@ -262,7 +262,8 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
$screen = get_current_screen();
$screen->add_help_tab( $tab_args );
$this->assertEquals(
$screen->get_help_tab( $tab ), array(
$screen->get_help_tab( $tab ),
array(
'id' => $tab,
'title' => 'Help!',
'content' => 'Some content',
@@ -352,7 +353,8 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
$tab_1 => $tab_1_args,
$tab_4 => $tab_4_args,
$tab_3 => $tab_3_args,
), $tabs
),
$tabs
);
$screen->remove_help_tab( $tab_1 );
+24 -12
View File
@@ -53,7 +53,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'Top Level' => 'template-top-level.php',
'Sub Dir' => 'subdir/template-sub-dir.php',
'This Template Header Is On One Line' => 'template-header.php',
), get_page_templates()
),
get_page_templates()
);
$theme = wp_get_theme( 'page-templates' );
@@ -66,7 +67,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'Top Level' => 'template-top-level.php',
'Sub Dir' => 'subdir/template-sub-dir.php',
'This Template Header Is On One Line' => 'template-header.php',
), get_page_templates()
),
get_page_templates()
);
}
@@ -83,13 +85,15 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
array(
'Top Level' => 'template-top-level-post-types.php',
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
), get_page_templates( null, 'foo' )
),
get_page_templates( null, 'foo' )
);
$this->assertEqualSetsWithIndex(
array(
'Top Level' => 'template-top-level-post-types.php',
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
), get_page_templates( null, 'post' )
),
get_page_templates( null, 'post' )
);
$this->assertEquals( array(), get_page_templates( null, 'bar' ) );
}
@@ -111,7 +115,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php',
'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php',
'Tilde in Post Type.' => '38766/tilde-post-types.php',
), get_page_templates( null, 'period' )
),
get_page_templates( null, 'period' )
);
$this->assertEqualSetsWithIndex(
array(
@@ -120,7 +125,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'Trailing Comma,' => '38766/trailing-comma-post-types.php',
'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php',
'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php',
), get_page_templates( null, 'full-stop' )
),
get_page_templates( null, 'full-stop' )
);
}
@@ -139,14 +145,16 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
'Top Level In A Child Theme' => 'template-top-level-post-types-child.php',
'Sub Dir In A Child Theme' => 'subdir/template-sub-dir-post-types-child.php',
), get_page_templates( null, 'foo' )
),
get_page_templates( null, 'foo' )
);
$this->assertEqualSetsWithIndex(
array(
'Top Level' => 'template-top-level-post-types.php',
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
), get_page_templates( null, 'post' )
),
get_page_templates( null, 'post' )
);
$this->assertEqualSetsWithIndex(
@@ -154,7 +162,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'Top Level' => 'template-top-level.php',
'Sub Dir' => 'subdir/template-sub-dir.php',
'This Template Header Is On One Line' => 'template-header.php',
), get_page_templates()
),
get_page_templates()
);
$this->assertEquals( array(), get_page_templates( null, 'bar' ) );
@@ -177,14 +186,16 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'subdir/template-sub-dir-post-types.php' => 'Sub Dir',
'template-top-level-post-types-child.php' => 'Top Level In A Child Theme',
'subdir/template-sub-dir-post-types-child.php' => 'Sub Dir In A Child Theme',
), $post_templates['foo']
),
$post_templates['foo']
);
$this->assertEqualSetsWithIndex(
array(
'template-top-level-post-types.php' => 'Top Level',
'subdir/template-sub-dir-post-types.php' => 'Sub Dir',
), $post_templates['post']
),
$post_templates['post']
);
$this->assertEqualSetsWithIndex(
@@ -192,7 +203,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
'template-top-level.php' => 'Top Level',
'subdir/template-sub-dir.php' => 'Sub Dir',
'template-header.php' => 'This Template Header Is On One Line',
), $post_templates['page']
),
$post_templates['page']
);
}