Perl::Critic::Policy::ControlStructures::ProhibitUnlessBlocks3pm
Write "if(! $condition)" instead of "unless($condition)".
Affiliation
This Policy is part of the core Perl::Critic distribution.
Overview
Conway discourages using "unless" because it leads to double-negatives that are hard to understand. Instead, reverse the logic and use "if".
unless($condition) { do_something() } #not okunless(! $no_flag) { do_something() } #really badif( ! $condition) { do_something() } #ok
This Policy only covers the block-form of "unless". For the postfix variety, see "ProhibitPostfixControls".
Configuration
This Policy is not configurable except for the standard options.
Releases
10 releases since Debian 5.0 (Lenny); the text changed 9 times.