Perl/Lint/Policy/ValuesAndExpressions/ProhibitMixedBooleanOperators.pm

filter: Statementstmt 41.3% 19 / 46 Branchbran 0.0% 0 / 30 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 22.5% 25 / 111 CC 22 SCAR 59.9
CC
22
Cov
20%
evaluate
506.0
BEGIN
1.0
BEGIN
1.0
CRAP 397.8
« 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
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
26 0 $token_type = $token->{type};
27  
28 0 ▶ if ($token_type == SEMI_COLON) {
Branch: 5 branches
BranchTrueFalseTotal
if ($token_type == 106) { } 0 0 0
elsif ($token_type == 107) { } 0 0 0
elsif ($token_type == 108) { } 0 0 0
elsif ($token_type == 52 or $token_type == 53 or $token_type == 68) { } 0 0 0
elsif ($token_type == 16 or $token_type == 14 or $token_type == 69 or $token_type == 18) { } 0 0 0
29 0 ▶ if ($left_paren_num <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_paren_num <= 0) 0 0 0
30 0 ▶ if (my $status = $context_for_each_depth[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $status = $context_for_each_depth[0]) 0 0 0
31 0 ▶ if ($status == INVALID) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 3) 0 0 0
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
BranchTrueFalseTotal
if (@context_for_each_depth and my $status = splice(@context_for_each_depth, $left_paren_num)) 0 0 0
Condition0%0/3
@context_for_each_depth and my $status = splice(@context_for_each_depth, $left_paren_num)
!ll&&!rl&&r
000
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)
ABresult
0X0
100
111
49 0 ▶ if ($status == INVALID) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 3) 0 0 0
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
l!l&&r!l&&!r
000
$token_type == 52 or $token_type == 53
l!l&&r!l&&!r
000
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
ABCresult
1XX1
01X1
0011
0000
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
BranchTrueFalseTotal
if (my $context = $context_for_each_depth[$left_paren_num]) 0 0 0
67 0 ▶ if ($context != NON_ALPHABETICAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($context != 2) 0 0 0
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
l!l&&r!l&&!r
000
$token_type == 16 or $token_type == 14 or $token_type == 69
l!l&&r!l&&!r
000
$token_type == 16 or $token_type == 14
l!l&&r!l&&!r
000
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
ABCDresult
1XXX1
01XX1
001X1
00011
00000
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
BranchTrueFalseTotal
if (my $context = $context_for_each_depth[$left_paren_num]) 0 0 0
81 0 ▶ if ($context != ALPHABETICAL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($context != 1) 0 0 0
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  
« Perl/Lint/Policy/ClassHierarchies/ProhibitOneArgBless.pm ↑ Summary Perl/Lint/Policy/RegularExpressions/RequireDotMatchAnything.pm »