logo
Free, Micro AI Code Reviews That Run on Git Commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, Micro AI Code Reviews That Run on Git Commit | Product Hunt git-lrc - Free, Micro AI Code Reviews That Run on Git Commit | Product Hunt

Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators - Write " !$foo && $bar || $baz

Affiliation

       This Policy is part of the core Perl::Critic distribution.

Author

       Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>

Configuration

       This Policy is not configurable except for the standard options.

Description

       Conway advises against combining the low-precedence booleans ( "and or not" ) with the high-precedence
       boolean operators ( "&& || !" ) in the same expression.  Unless you fully understand the differences
       between the high and low-precedence operators, it is easy to misinterpret expressions that use both.  And
       even if you do understand them, it is not always clear if the author actually intended it.

           next if not $foo || $bar;  #not ok
           next if !$foo || $bar;     #ok
           next if !( $foo || $bar ); #ok

Name

       Perl::Critic::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators - Write " !$foo && $bar || $baz
       " instead of " not $foo && $bar or $baz".

See Also