WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/17/2018 01:50:26 AM (3 years ago)
Author:
pento
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/wpInsertPost.php

    r42380 r43571  
    1313    static function wpSetUpBeforeClass( $factory ) {
    1414        self::$user_ids = array(
    15             'administrator' => $factory->user->create( array(
    16                 'role' => 'administrator',
    17             ) ),
    18             'contributor'   => $factory->user->create( array(
    19                 'role' => 'contributor',
    20             ) ),
     15            'administrator' => $factory->user->create(
     16                array(
     17                    'role' => 'administrator',
     18                )
     19            ),
     20            'contributor'   => $factory->user->create(
     21                array(
     22                    'role' => 'contributor',
     23                )
     24            ),
    2125        );
    2226
     
    3741        parent::setUp();
    3842
    39         register_post_type( 'mapped_meta_caps', array(
    40             'capability_type' => array( 'mapped_meta_cap', 'mapped_meta_caps' ),
    41             'map_meta_cap'    => true,
    42         ) );
    43 
    44         register_post_type( 'unmapped_meta_caps', array(
    45             'capability_type' => array( 'unmapped_meta_cap', 'unmapped_meta_caps' ),
    46             'map_meta_cap'    => false,
    47         ) );
    48 
    49         register_post_type( 'no_admin_caps', array(
    50             'capability_type' => array( 'no_admin_cap', 'no_admin_caps' ),
    51             'map_meta_cap'    => false,
    52         ) );
     43        register_post_type(
     44            'mapped_meta_caps',
     45            array(
     46                'capability_type' => array( 'mapped_meta_cap', 'mapped_meta_caps' ),
     47                'map_meta_cap'    => true,
     48            )
     49        );
     50
     51        register_post_type(
     52            'unmapped_meta_caps',
     53            array(
     54                'capability_type' => array( 'unmapped_meta_cap', 'unmapped_meta_caps' ),
     55                'map_meta_cap'    => false,
     56            )
     57        );
     58
     59        register_post_type(
     60            'no_admin_caps',
     61            array(
     62                'capability_type' => array( 'no_admin_cap', 'no_admin_caps' ),
     63                'map_meta_cap'    => false,
     64            )
     65        );
    5366    }
    5467
     
    180193        wp_set_current_user( self::$user_ids['contributor'] );
    181194
    182         $post_id = $this->factory()->post->create( array(
    183             'post_title'   => 'Jefferson claim: nice to have Washington on your side.',
    184             'post_content' => "I’m in the cabinet. I am complicit in watching him grabbin’ at power and kiss it.\n\nIf Washington isn’t gon’ listen to disciplined dissidents, this is the difference: this kid is out!",
    185             'post_type'    => $post_type,
    186             'post_name'    => 'new-washington',
    187             'post_status'  => 'pending',
    188         ) );
     195        $post_id = $this->factory()->post->create(
     196            array(
     197                'post_title'   => 'Jefferson claim: nice to have Washington on your side.',
     198                'post_content' => "I’m in the cabinet. I am complicit in watching him grabbin’ at power and kiss it.\n\nIf Washington isn’t gon’ listen to disciplined dissidents, this is the difference: this kid is out!",
     199                'post_type'    => $post_type,
     200                'post_name'    => 'new-washington',
     201                'post_status'  => 'pending',
     202            )
     203        );
    189204
    190205        $expected = '';
    191         $actual = get_post_field( 'post_name', $post_id );
     206        $actual   = get_post_field( 'post_name', $post_id );
    192207
    193208        $this->assertSame( $expected, $actual );
    194209
    195210        // Now update the post.
    196         wp_update_post( array(
    197             'ID' => $post_id,
    198             'post_title' => 'Hamilton has Washington on side: Jefferson',
    199             'post_name'  => 'edited-washington',
    200         ) );
     211        wp_update_post(
     212            array(
     213                'ID'         => $post_id,
     214                'post_title' => 'Hamilton has Washington on side: Jefferson',
     215                'post_name'  => 'edited-washington',
     216            )
     217        );
    201218
    202219        $expected = '';
    203         $actual = get_post_field( 'post_name', $post_id );
     220        $actual   = get_post_field( 'post_name', $post_id );
    204221
    205222        $this->assertSame( $expected, $actual );
     
    215232        wp_set_current_user( self::$user_ids['administrator'] );
    216233
    217         $post_id = $this->factory()->post->create( array(
    218             'post_title'   => 'What is the Conner Project?',
    219             'post_content' => "Evan Hansen’s last link to his friend Conner is a signature on his broken arm.",
    220             'post_type'    => $post_type,
    221             'post_name'    => 'dear-evan-hansen-explainer',
    222             'post_status'  => 'pending',
    223         ) );
     234        $post_id = $this->factory()->post->create(
     235            array(
     236                'post_title'   => 'What is the Conner Project?',
     237                'post_content' => 'Evan Hansen’s last link to his friend Conner is a signature on his broken arm.',
     238                'post_type'    => $post_type,
     239                'post_name'    => 'dear-evan-hansen-explainer',
     240                'post_status'  => 'pending',
     241            )
     242        );
    224243
    225244        $expected = 'dear-evan-hansen-explainer';
    226         $actual = get_post_field( 'post_name', $post_id );
     245        $actual   = get_post_field( 'post_name', $post_id );
    227246
    228247        $this->assertSame( $expected, $actual );
    229248
    230249        // Now update the post.
    231         wp_update_post( array(
    232             'ID' => $post_id,
    233             'post_title' => 'Conner Project to close',
    234             'post_name'  => 'dear-evan-hansen-spoiler',
    235         ) );
     250        wp_update_post(
     251            array(
     252                'ID'         => $post_id,
     253                'post_title' => 'Conner Project to close',
     254                'post_name'  => 'dear-evan-hansen-spoiler',
     255            )
     256        );
    236257
    237258        $expected = 'dear-evan-hansen-spoiler';
    238         $actual = get_post_field( 'post_name', $post_id );
     259        $actual   = get_post_field( 'post_name', $post_id );
    239260
    240261        $this->assertSame( $expected, $actual );
     
    252273        wp_set_current_user( self::$user_ids['administrator'] );
    253274
    254         $post_id = $this->factory()->post->create( array(
    255             'post_title'   => 'Everything is legal in New Jersey',
    256             'post_content' => 'Shortly before his death, Philip Hamilton was heard to claim everything was legal in the garden state.',
    257             'post_type'    => 'no_admin_caps',
    258             'post_name'    => 'yet-another-duel',
    259             'post_status'  => 'pending',
    260         ) );
     275        $post_id = $this->factory()->post->create(
     276            array(
     277                'post_title'   => 'Everything is legal in New Jersey',
     278                'post_content' => 'Shortly before his death, Philip Hamilton was heard to claim everything was legal in the garden state.',
     279                'post_type'    => 'no_admin_caps',
     280                'post_name'    => 'yet-another-duel',
     281                'post_status'  => 'pending',
     282            )
     283        );
    261284
    262285        $expected = '';
    263         $actual = get_post_field( 'post_name', $post_id );
     286        $actual   = get_post_field( 'post_name', $post_id );
    264287
    265288        $this->assertSame( $expected, $actual );
    266289
    267290        // Now update the post.
    268         wp_update_post( array(
    269             'ID' => $post_id,
    270             'post_title' => 'Ten things illegal in New Jersey',
    271             'post_name'  => 'foreshadowing-in-nj',
    272         ) );
     291        wp_update_post(
     292            array(
     293                'ID'         => $post_id,
     294                'post_title' => 'Ten things illegal in New Jersey',
     295                'post_name'  => 'foreshadowing-in-nj',
     296            )
     297        );
    273298
    274299        $expected = '';
    275         $actual = get_post_field( 'post_name', $post_id );
     300        $actual   = get_post_field( 'post_name', $post_id );
    276301
    277302        $this->assertSame( $expected, $actual );
Note: See TracChangeset for help on using the changeset viewer.