Perl/Lint/Policy/Variables/ProhibitMatchVars.pm

filter: Statementstmt 42.1% 16 / 38 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 21.2% 21 / 99 CC 20 SCAR 58.2
CC
20
Cov
20%
evaluate
420.0
BEGIN
1.0
BEGIN
1.0
CRAP 336.2
« Perl/Lint/Policy/BuiltinFunctions/ProhibitVoidMap.pm ↑ Summary Perl/Lint/Policy/InputOutput/ProhibitBacktickOperators.pm »
1 package Perl::Lint::Policy::Variables::ProhibitMatchVars;
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 => 'Match variable used',
9 EXPL => [82],
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=20 SCAR=60.4
Pod undocumented
13 0 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 0 my @violations;
16 0 ▶ for (my $i = 0, my $token_type, my $token_data; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
17 0 $token_type = $token->{type};
18 0 $token_data = $token->{data};
19  
20 0 ▶ if ($token_type == SPECIFIC_VALUE) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token_type == 137) { } 0 0 0
elsif ($token_type == 194) { } 0 0 0
elsif ($token_type == 94 and $token_data eq 'English') { } 0 0 0
21 0 ▶ if ($token_data eq q{$`} || $token_data eq q{$&} || $token_data eq q{$'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_data eq "\$`" or $token_data eq "\$&" or $token_data eq "\$'") 0 0 0
Condition0%0/6
$token_data eq "\$`" or $token_data eq "\$&" or $token_data eq "\$'"
l!l&&r!l&&!r
000
$token_data eq "\$`" or $token_data eq "\$&"
l!l&&r!l&&!r
000
MC/DC0%0/3
$token_data eq "\$`" or $token_data eq "\$&" or $token_data eq "\$'"
$token_data eq "\$`" $token_data eq "\$&" $token_data eq "\$'"
Truth table0%0/4
A or B or C
A= $token_data eq "\$`"B= $token_data eq "\$&"C= $token_data eq "\$'"
ABCresult
1XX1
01X1
0011
0000
22 push @violations, {
23 filename => $file,
24 line => $token->{line},
25 0 description => DESC,
26 explanation => EXPL,
27 policy => __PACKAGE__,
28 };
29 }
30 }
31 elsif ($token_type == GLOBAL_VAR) {
32 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($token_data eq "\$PREMATCH" or $token_data eq "\$MATCH" or $token_data eq "\$POSTMATCH") 0 0 0
Condition0%0/6
$token_data eq "\$PREMATCH" or $token_data eq "\$MATCH" or $token_data eq "\$POSTMATCH"
l!l&&r!l&&!r
000
$token_data eq "\$PREMATCH" or $token_data eq "\$MATCH"
l!l&&r!l&&!r
000
MC/DC0%0/3
$token_data eq "\$PREMATCH" or $token_data eq "\$MATCH" or $token_data eq "\$POSTMATCH"
$token_data eq "\$PREMATCH" $token_data eq "\$MATCH" $token_data eq "\$POSTMATCH"
Truth table0%0/4
A or B or C
A= $token_data eq "\$PREMATCH"B= $token_data eq "\$MATCH"C= $token_data eq "\$POSTMATCH"
ABCresult
1XX1
01X1
0011
0000
33 $token_data eq '$PREMATCH' ||
34 $token_data eq '$MATCH' ||
35 $token_data eq '$POSTMATCH'
36 ) {
37 push @violations, {
38 filename => $file,
39 line => $token->{line},
40 0 description => DESC,
41 explanation => EXPL,
42 policy => __PACKAGE__,
43 };
44 }
45 }
46 ▶ elsif ($token_type == USED_NAME && $token_data eq 'English') {
Condition0%0/3
$token_type == 94 and $token_data eq "English"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 94 and $token_data eq "English"
$token_type == 94 $token_data eq "English"
Truth table0%0/3
A and B
A= $token_type == 94B= $token_data eq "English"
ABresult
0X0
100
111
47 0 $token = $tokens->[++$i];
48  
49 0 ▶ if ($token->{type} == REG_LIST) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 147) 0 0 0
50 0 $i++; # Skip the first REG_DELIM
51 0 ▶ for ($i++; $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $tokens->[$i]) 0 0 0
52 0 $token_type = $token->{type};
53 0 ▶ if ($token_type == REG_DELIM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 151) { } 0 0 0
elsif ($token_type == 187) { } 0 0 0
54 0 last;
55 }
56 elsif ($token_type == REG_EXP) {
57 0 my @regexps = split / /, $token->{data};
58 0 for my $regexp (@regexps) {
59 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($regexp eq "\$PREMATCH" or $regexp eq "\$MATCH" or $regexp eq "\$POSTMATCH") 0 0 0
Condition0%0/6
$regexp eq "\$PREMATCH" or $regexp eq "\$MATCH" or $regexp eq "\$POSTMATCH"
l!l&&r!l&&!r
000
$regexp eq "\$PREMATCH" or $regexp eq "\$MATCH"
l!l&&r!l&&!r
000
MC/DC0%0/3
$regexp eq "\$PREMATCH" or $regexp eq "\$MATCH" or $regexp eq "\$POSTMATCH"
$regexp eq "\$PREMATCH" $regexp eq "\$MATCH" $regexp eq "\$POSTMATCH"
Truth table0%0/4
A or B or C
A= $regexp eq "\$PREMATCH"B= $regexp eq "\$MATCH"C= $regexp eq "\$POSTMATCH"
ABCresult
1XX1
01X1
0011
0000
60 $regexp eq '$PREMATCH' ||
61 $regexp eq '$MATCH' ||
62 $regexp eq '$POSTMATCH'
63 ) {
64 push @violations, {
65 filename => $file,
66 line => $token->{line},
67 0 description => DESC,
68 explanation => EXPL,
69 policy => __PACKAGE__,
70 };
71 }
72 }
73 }
74 }
75 }
76 }
77 }
78  
79 0 return \@violations;
80 }
81  
82 2 1;
83  
« Perl/Lint/Policy/BuiltinFunctions/ProhibitVoidMap.pm ↑ Summary Perl/Lint/Policy/InputOutput/ProhibitBacktickOperators.pm »