« Perl/Lint/Policy/CodeLayout/ProhibitParensWithBuiltins.pm
↑ Summary
Perl/Lint/Policy/ValuesAndExpressions/ProhibitQuotesAsQuotelikeOperatorDelimiters.pm »
| 1 | package Perl::Lint::Policy::Variables::ProhibitConditionalDeclarations; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Perl::Lint::Constants::Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use parent "Perl::Lint::Policy"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | DESC => q{Variable declared in conditional statement}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | EXPL => q{Declare variables outside of the condition}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | my ($class, $file, $tokens) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my @violations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my $token_num = scalar @$tokens; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | for (my $i = 0; $i < $token_num; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $token = $tokens->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if ($token_type == VAR_DECL || $token_type == OUR_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token_type == 62 or $token_type == 91
MC/DC0%0/2
$token_type == 62 or $token_type == 91
$token_type == 62
$token_type == 91
Truth table0%0/3
A or B
A= $token_type == 62B= $token_type == 91
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | for ($i++; $i < $token_num; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $token = $tokens->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | if ($token->{type} == ASSIGN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $is_before_right_paren = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | for ($i++; $i < $token_num; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $token = $tokens->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if ($token_type == RIGHT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $is_before_right_paren = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/12
$token_type == 96 or $token_type == 99 or $token_type == 132 or $token_type == 133 or $token_type == 134
$token_type == 96 or $token_type == 99 or $token_type == 132 or $token_type == 133
$token_type == 96 or $token_type == 99 or $token_type == 132
$token_type == 96 or $token_type == 99
MC/DC0%0/5
$token_type == 96 or $token_type == 99 or $token_type == 132 or $token_type == 133 or $token_type == 134
$token_type == 96
$token_type == 99
$token_type == 132
$token_type == 133
$token_type == 134
Truth table0%0/6
A or B or C or D or E
A= $token_type == 96B= $token_type == 99C= $token_type == 132D= $token_type == 133E= $token_type == 134
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | $token_type == IF_STATEMENT || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | $token_type == UNLESS_STATEMENT || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | $token_type == WHILE_STATEMENT || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $token_type == FOR_STATEMENT || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | $token_type == FOREACH_STATEMENT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | push @violations, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | filename => $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | description => DESC, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | explanation => EXPL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my $_is_before_right_paren = $is_before_right_paren; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $is_before_right_paren = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($_is_before_right_paren && $token_type == LEFT_BRACE) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_is_before_right_paren and $token_type == 109
MC/DC0%0/2
$_is_before_right_paren and $token_type == 109
$_is_before_right_paren
$token_type == 109
Truth table0%0/3
A and B
A= $_is_before_right_parenB= $token_type == 109
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | last if $token->{type} == SEMI_COLON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | last if $token->{type} == SEMI_COLON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return \@violations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||