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 Gabor Szabo <gabor at szabgab dot com>
Full name Gabor Szabo <gabor at szabgab dot com>
Date 2015-05-25 12:22:37 PDT
Message That is_ok is actually an indirect method call that I am also getting rid
of.

I'd start by considering any use of short-circuit which is not in a
conditional as overuse and maybe let through a few exception such as "open
or die". Or maybe those exceptions would be configurable.

Gabor


On Mon, May 25, 2015 at 10:11 PM, Jeffrey Ryan Thalhammer <jeff at thaljef dot org>
wrote:

> 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 | 3 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: