I just came by the following line of code:
my $foo = $bar if $cond;
I'm going to fix this since it will of course lead to subtle bugs.
Is there a version of Perl, a module, or pragma that would warn if this type of statement was reached?
For now I'm just going to use a combination of grep and PPI to scan the codebase to fix all of these issues. Have found a total of 102 of them thus far. However, a way of automatically warning other programmers if they add a new invalid line would be helpful.
The Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations
policy in perlcritic
warns about these constructions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With