Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Re: [Perl-Critic] Policy to catch overuse of short-circuit ?

perlcritic
Discussion topic

Back to topic list

Re: [Perl-Critic] Policy to catch overuse of short-circuit ?

Author thaljef
Full name Jeffrey Ryan Thalhammer
Date 2015-05-25 12:12:19 PDT
Message I’m guilty of doing that once in a while. Although mine would probably look
like this:

$node = $obj and last if is_ok $obj;

In theory, your example would violate ProhibitCommaSeparat​edStatements
<https://metacpan.org​/pod/Perl::Critic::P​olicy::ValuesAndExpr​essions::ProhibitCom​maSeparatedStatement​s>.
But it doesn’t catch this one, probably because it doesn’t know the arity
of is_ok.

It would be very easy to write a policy that forbid multiple and and or in
a single statement, but that is also a bit different from your example.
You’d have to decide exactly what “overuse” means.

-Jeff
 
Attachments

« Previous message in topic | 2 of 3 | Next message in topic »

Messages

Show all messages in topic

[Perl-Critic] Policy to catch overuse of short-circuit ? Gabor Szabo <gabor at szabgab dot com> Gabor Szabo <gabor at szabgab dot com> 2015-05-25 06:53:12 PDT
     Re: [Perl-Critic] Policy to catch overuse of short-circuit ? thaljef Jeffrey Ryan Thalhammer 2015-05-25 12:12:19 PDT
         Re: [Perl-Critic] Policy to catch overuse of short-circuit ? Gabor Szabo <gabor at szabgab dot com> Gabor Szabo <gabor at szabgab dot com> 2015-05-25 12:22:37 PDT
Messages per page: