[wp-trac] [WordPress Trac] #27882: Address some issues found running Scrutinizer
WordPress Trac
noreply at wordpress.org
Mon Jun 2 19:33:53 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 jdgrimes):
Replying to [comment:82 azaozz]:
> 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 there were
some.
Maybe styling them something like this would improve readability?
{{{
switch ( $var ) {
case 1:
/* ... */
break;
case 2:
/* ... */
return;
case 3:
/* ... */
// fallthru
case 4:
/* ... */
exit;
default:
/* ... */
}
}}}
I think adding a comment whenever one `case` falls through into another is
especially useful. But, you know, everybody has their own style.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27882#comment:85>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list