[wp-trac] [WordPress Trac] #44600: Update WPCS to 1.0.0, and enforce coding standards

WordPress Trac noreply at wordpress.org
Thu Aug 16 14:01:01 UTC 2018


#44600: Update WPCS to 1.0.0, and enforce coding standards
------------------------------+-------------------------------
 Reporter:  pento             |       Owner:  pento
     Type:  task (blessed)    |      Status:  assigned
 Priority:  normal            |   Milestone:  5.0
Component:  Build/Test Tools  |     Version:  trunk
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:  coding-standards
------------------------------+-------------------------------

Comment (by azaozz):

 Just pointing out that I'm (still) very much against encouraging multi-
 line parameters that are multi-line themselves. The above example looks
 "cute":

 {{{
 do_action(
         'upgrader_process_complete',
         $this,
         array(
                 'action' => 'update',
                 'type'   => 'core',
         )
 );
 }}}

 But in reality we are "approving" stuff like this:

 {{{
 $content = apply_filters(
         'wp_comment_no_reply',        // First arg.
         '',                           // Second arg.
         array(                        // Third arg.
                 'position' => $position,
                 'checkbox' => $checkbox,
                 'mode'     => $mode,
         ),
         esc_html(                     // Forth arg.
                 sprintf(              // Forth.one arg.
                         __( 'This is a long piece of text that should
 never be inside of a function call. Even worse: it might end up in a
 nested multi-line function call. %s, %s.' ),
                         add_query_arg(   // Forth.one.two arg.
                                 array(   // Forth.one.three arg.
                                         'bah_where_am_i'     =>
 'undefined', // Forth.one.three.one arg.
                                         'how_did_i_get_here' => 'who-
 knows', // Forth.one.three.two arg.
                                 ),
                                 remove_query_arg( // Ughhh, getting worse
 and worse.
                                         array(
                                                 '_wp_http_referer', //
 Forth.one.two.two.one arg.
                                                 '_wpnonce', // I give up
 :)
                                                 'error',
                                                 'message',
                                                 'paged',
                                         ),
                                         wp_unslash(
 $_SERVER['REQUEST_URI'] )
                                  )
                         ),
                         '<p>' . __( 'This is another long piece of text
 that should never be inside of a function call...' ) . '</p>'
                 )
         )
 );
 }}}

 IMHO this is bad/ugly way to write. It is hard to read with many
 readability problems:
 - Many levels of unneeded indentation.
 - No (good) way to add inline docs. Adding few docblocks will make this
 even harder to read.
 - No good way to even add simple inline comments, see above.

 I understand this is difficult (impossible?) to fix with the parser.
 Thinking to amend the core coding standards to strongly discourage such
 code, even only as a recommendation.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44600#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list