Perl/Lint/Policy/Variables/RequireLexicalLoopIterators.pm

filter: Statementstmt 51.6% 16 / 31 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 31.3% 21 / 67 CC 10 SCAR 43.0
CC
10
Cov
30%
evaluate
110.0
BEGIN
1.0
BEGIN
1.0
CRAP 73.7
« Perl/Lint/Policy/Variables/ProhibitAugmentedAssignmentInDeclaration.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/ProhibitUniversalCan.pm »
1 package Perl::Lint::Policy::Variables::RequireLexicalLoopIterators;
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 => 'Loop iterator is not lexical',
9 EXPL => [108],
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=10 SCAR=47.0
Pod undocumented
13 0 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 0 my $perl_version_threshold = 5.003;
16 0 my $perl_version = 6; # to hit always on default. Yes, this is Perl6 :)
17  
18 0 my @violations;
19 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
20 0 $token_type = $token->{type};
21  
22 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 133 or $token_type == 134 and $perl_version > $perl_version_threshold) { } 0 0 0
elsif ($token_type == 93 or $token_type == 71) { } 0 0 0
Condition0%0/6
$token_type == 133 or $token_type == 134 and $perl_version > $perl_version_threshold
l!l&&r!l&&!r
000
$token_type == 134 and $perl_version > $perl_version_threshold
!ll&&!rl&&r
000
MC/DC0%0/3
$token_type == 133 or $token_type == 134 and $perl_version > $perl_version_threshold
$token_type == 133 $token_type == 134 $perl_version > $perl_version_threshold
Truth table0%0/4
A or B and C
A= $token_type == 133B= $token_type == 134C= $perl_version > $perl_version_threshold
ABCresult
1XX1
0111
00X0
0100
23 $token_type == FOR_STATEMENT ||
24 ($token_type == FOREACH_STATEMENT && $perl_version > $perl_version_threshold)
25 ) {
26 0 $token = $tokens->[++$i];
27 0 $token_type = $token->{type};
28  
29 0 ▶ if ($token_type != VAR_DECL && $token_type != LEFT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type != 62 and $token_type != 107) 0 0 0
Condition0%0/3
$token_type != 62 and $token_type != 107
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type != 62 and $token_type != 107
$token_type != 62 $token_type != 107
Truth table0%0/3
A and B
A= $token_type != 62B= $token_type != 107
ABresult
0X0
100
111
30 push @violations, {
31 filename => $file,
32 line => $token->{line},
33 0 description => DESC,
34 explanation => EXPL,
35 policy => __PACKAGE__,
36 };
37 }
38 }
39 ▶ elsif ($token_type == USE_DECL || $token_type == REQUIRE_DECL) {
Condition0%0/3
$token_type == 93 or $token_type == 71
l!l&&r!l&&!r
000
MC/DC0%0/2
$token_type == 93 or $token_type == 71
$token_type == 93 $token_type == 71
Truth table0%0/3
A or B
A= $token_type == 93B= $token_type == 71
ABresult
1X1
011
000
40 0 $token = $tokens->[++$i];
41 0 ▶ if ($token->{type} == DOUBLE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 171) 0 0 0
42 0 $perl_version = $token->{data};
43 }
44 }
45 }
46  
47 0 return \@violations;
48 }
49  
50 2 1;
51  
« Perl/Lint/Policy/Variables/ProhibitAugmentedAssignmentInDeclaration.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/ProhibitUniversalCan.pm »