-
-
29 Jul 2016 17:45:27 UTC
- Distribution: Perl-Critic-Policy-BuiltinFunctions-ProhibitReturnOr
- Module version: 0.01
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (0)
- Testers (803 / 0 / 1)
- Kwalitee
Bus factor: 0- 92.45% Coverage
- License: perl_5
- Perl: v5.8.1
- Activity
24 month- Tools
- Download (9.38KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- Jeremy Leader.
NAME
Perl::Critic::Policy::BuiltinFunctions::ProhibitReturnOr - Check for "return $x or ..."
DESCRIPTION
return
when encountered in an expression returns from the enclosing subroutine, without evaluating the rest of the expression. So a lower-precedence operator (or
,and
,xor
) won't get evaluated after areturn
. This most commonly appears as the mis-idiom:# NO! DON'T DO THIS! return $x or die 'Aaaagh! $x was zero!';
Instead, use the higher-precedence
||
operator, like this:return $x || die 'Aaaagh! $x was zero!';
Or separate the two operations, like this:
$x or die 'Aaaagh! $x was zero!'; return $x;
CONFIGURATION
This Policy is not configurable except for the standard options.
LICENSE
Copyright (C) 2016 Jeremy Leader.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
Jeremy Leader <jeremy@ziprecruiter.com>
SEE ALSO
Module Install Instructions
To install Perl::Critic::Policy::BuiltinFunctions::ProhibitReturnOr, copy and paste the appropriate command in to your terminal.
cpanm Perl::Critic::Policy::BuiltinFunctions::ProhibitReturnOr
perl -MCPAN -e shell install Perl::Critic::Policy::BuiltinFunctions::ProhibitReturnOr
For more information on module installation, please visit the detailed CPAN module installation guide.