Perl/Lint/Policy/BuiltinFunctions/ProhibitStringyEval.pm

filter: Statementstmt 33.3% 16 / 48 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 22.1% 21 / 95 CC 19 SCAR 57.1
CC
19
Cov
19%
evaluate
380.0
BEGIN
1.0
BEGIN
1.0
CRAP 301.0
« Perl/Lint/Policy/TestingAndDebugging/ProhibitNoWarnings.pm ↑ Summary Perl/Lint/Policy/RegularExpressions/ProhibitFixedStringMatches.pm »
1 package Perl::Lint::Policy::BuiltinFunctions::ProhibitStringyEval;
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 => 'Expression form of "eval"',
9 EXPL => [161],
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=19 SCAR=59.4
Pod undocumented
13 0 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 0 ▶ my $allow_includes = $args->{prohibit_stringy_eval}->{allow_includes} || 0;
Condition0%0/2
$args->{'prohibit_stringy_eval'}{'allow_includes'} || 0
l!l
00
MC/DC0%0/1
$args->{'prohibit_stringy_eval'}{'allow_includes'} || 0
$args->{'prohibit_stringy_eval'}{'allow_includes'}
Truth table0%0/2
A
A= $args->{'prohibit_stringy_eval'}{'allow_includes'}
Aresult
11
00
16  
17 0 my @violations;
18 0 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
19 0 my $token_type = $token->{type};
20 0 my $token_data = $token->{data};
21  
22 0 ▶ if ($token_type == BUILTIN_FUNC && $token_data eq 'eval') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 70 and $token_data eq "eval") 0 0 0
Condition0%0/3
$token_type == 70 and $token_data eq "eval"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 70 and $token_data eq "eval"
$token_type == 70 $token_data eq "eval"
Truth table0%0/3
A and B
A= $token_type == 70B= $token_data eq "eval"
ABresult
0X0
100
111
23 0 $token = $tokens->[++$i];
24 0 ▶ if ($token->{type} == LEFT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 107) 0 0 0
25 0 $token = $tokens->[++$i];
26 0 ▶ if ($token->{type} == RIGHT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 108) 0 0 0
27 0 next;
28 }
29 }
30 0 $token_type = $token->{type};
31  
32 0 ▶ if ($token_type != LEFT_BRACE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type != 109) 0 0 0
33 0 ▶ if ($allow_includes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($allow_includes) 0 0 0
34 0 ▶ if ($token_type == STRING) {
Branch: 4 branches
BranchTrueFalseTotal
if ($token_type == 172) { } 0 0 0
elsif ($token_type == 173) { } 0 0 0
elsif ($token_type == 146) { } 0 0 0
elsif ($token_type == 145) { } 0 0 0
35 0 ▶ if ($token->{data} =~ /\A(?:use|require)[^;]*(?:;|;\s*1;)?\Z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} =~ /\A(?:use|require)[^;]*(?:;|;\s*1;)?\Z/) 0 0 0
36 0 next;
37 }
38 }
39 elsif ($token_type == RAW_STRING) {
40 0 ▶ if ($token->{data} =~ /\A(?:use|require)\s+([^;\s]+)[^;]*(?:;|;\s*1;)?\Z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} =~ /\A(?:use|require)\s+([^;\s]+)[^;]*(?:;|;\s*1;)?\Z/) 0 0 0
41 0 ▶ if ($1 !~ /\A\$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($1 =~ /\A\$/) 0 0 0
42 0 next;
43 }
44 }
45 }
46 elsif ($token_type == REG_DOUBLE_QUOTE) {
47 0 $i += 2; # skip reg delimiter
48 0 $token = $tokens->[$i];
49 0 ▶ if ($token->{data} =~ /\A(?:use|require)[^;]*(?:;|;\s*1;)?\Z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} =~ /\A(?:use|require)[^;]*(?:;|;\s*1;)?\Z/) 0 0 0
50 0 next;
51 }
52 }
53 elsif ($token_type == REG_QUOTE) {
54 0 $i += 2; # skip reg delimiter
55 0 $token = $tokens->[$i];
56 0 ▶ if ($token->{data} =~ /\A(?:use|require)\s+([^;\s]+)[^;]*(?:;|;\s*1;)?\Z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} =~ /\A(?:use|require)\s+([^;\s]+)[^;]*(?:;|;\s*1;)?\Z/) 0 0 0
57 0 ▶ if ($1 !~ /\A\$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($1 =~ /\A\$/) 0 0 0
58 0 next;
59 }
60 }
61 }
62 }
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 0 return \@violations;
76 }
77  
78 2 1;
79  
« Perl/Lint/Policy/TestingAndDebugging/ProhibitNoWarnings.pm ↑ Summary Perl/Lint/Policy/RegularExpressions/ProhibitFixedStringMatches.pm »