Subject: | [PATCH] a policy to prohibit unless-else |
Date: | Sat, 22 Dec 2012 22:31:04 +0000 |
To: | bug-Perl-Critic [...] rt.cpan.org |
From: | "brian m. carlson" <sandals [...] crustytoothpaste.net> |
Reading and understanding unless-elsif-else chains is difficult because
one has to think about the inverse of the condition for the unless, and
then the inverse of *that* for the else. It's simply clearer and more
understandable to either invert the position of the blocks (for simple
unless-else) and use if-else or to just use an appropriate negation in
the initial condition for more complex chains.
Included is a patch against 1.118 that provides a ProhibitUnlessElse
policy that checks for this specific usage. Although I wrote this on my
own, this policy implements a standard we have at $DAYJOB that I would
very much like to have Perl::Critic check for. It's based off the
ProhibitCascadingIfElse policy.
--
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
Message body is not shown because sender requested not to inline it.
Message body not shown because it is not plain text.