[wp-trac] [WordPress Trac] #27882: Address some issues found running Scrutinizer

WordPress Trac noreply at wordpress.org
Mon Jun 2 16:50:38 UTC 2014


#27882: Address some issues found running Scrutinizer
----------------------------+-----------------------
 Reporter:  wonderboymusic  |       Owner:
     Type:  defect (bug)    |      Status:  reopened
 Priority:  normal          |   Milestone:  4.0
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  needs-patch     |     Focuses:
----------------------------+-----------------------

Comment (by azaozz):

 Replying to [comment:80 wonderboymusic]:
 > Adds a unit test to demonstrate that the order of `case` and `default`
 in a `switch` statement does not matter.

 The order may not matter but makes it (much) harder to read/follow when
 `default` is not at the bottom. Same for the unreachable `break;` after
 `return` and `die()`. As far as I remember these were added for
 readability as switch() is one of the "harder to read" constructs,
 especially for inexperienced users. (Omitting a `break` merges the cases,
 some people miss or misunderstand that).

 I don't particularly mind either way, but maybe we need to add some rules
 for `switch()` to the coding standards. Few years ago here were some.

 Not sure we need a "demonstration test". Also it is not complete: it
 doesn't test the default case.

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


More information about the wp-trac mailing list