« Perl/Lint/Policy/ClassHierarchies/ProhibitOneArgBless.pm
↑ Summary
Perl/Lint/Policy/RegularExpressions/RequireDotMatchAnything.pm »
| 1 | package Perl::Lint::Policy::ValuesAndExpressions::ProhibitMixedBooleanOperators; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 => 'Mixed high and low-precedence booleans', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | EXPL => [70], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ALPHABETICAL => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | NON_ALPHABETICAL => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | INVALID => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=22 SCAR=62.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my @violations; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | my @context_for_each_depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my $left_paren_num = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | for (my $i = 0, my $token_type; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ($token_type == SEMI_COLON) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ($left_paren_num <= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if (my $status = $context_for_each_depth[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if ($status == INVALID) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | push @violations, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | filename => $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | description => DESC, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | explanation => EXPL, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | @context_for_each_depth = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | elsif ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $left_paren_num++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | elsif ($token_type == RIGHT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if (@context_for_each_depth and my $status = splice @context_for_each_depth, $left_paren_num) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@context_for_each_depth and my $status = splice(@context_for_each_depth, $left_paren_num)
MC/DC0%0/2
@context_for_each_depth and my $status = splice(@context_for_each_depth, $left_paren_num)
@context_for_each_depth
my $status = splice(@context_for_each_depth, $left_paren_num)
Truth table0%0/3
A and B
A= @context_for_each_depthB= my $status = splice(@context_for_each_depth, $left_paren_num)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ($status == INVALID) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | push @violations, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | filename => $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | description => DESC, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | explanation => EXPL, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $left_paren_num--; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$token_type == 52 or $token_type == 53 or $token_type == 68
$token_type == 52 or $token_type == 53
MC/DC0%0/3
$token_type == 52 or $token_type == 53 or $token_type == 68
$token_type == 52
$token_type == 53
$token_type == 68
Truth table0%0/4
A or B or C
A= $token_type == 52B= $token_type == 53C= $token_type == 68
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | $token_type == AND || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | $token_type == OR || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | $token_type == NOT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if (my $context = $context_for_each_depth[$left_paren_num]) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ($context != NON_ALPHABETICAL) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $context_for_each_depth[$left_paren_num] = INVALID; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $context_for_each_depth[$left_paren_num] = NON_ALPHABETICAL; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$token_type == 16 or $token_type == 14 or $token_type == 69 or $token_type == 18
$token_type == 16 or $token_type == 14 or $token_type == 69
$token_type == 16 or $token_type == 14
MC/DC0%0/4
$token_type == 16 or $token_type == 14 or $token_type == 69 or $token_type == 18
$token_type == 16
$token_type == 14
$token_type == 69
$token_type == 18
Truth table0%0/5
A or B or C or D
A= $token_type == 16B= $token_type == 14C= $token_type == 69D= $token_type == 18
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | $token_type == ALPHABET_AND || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | $token_type == ALPHABET_OR || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | $token_type == ALPHABET_NOT || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | $token_type == ALPHABET_XOR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if (my $context = $context_for_each_depth[$left_paren_num]) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($context != ALPHABETICAL) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $context_for_each_depth[$left_paren_num] = INVALID; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $context_for_each_depth[$left_paren_num] = ALPHABETICAL; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | return \@violations; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||