Perl/Lint/Policy/InputOutput/ProhibitReadlineInForLoop.pm

filter: Statementstmt 35.5% 16 / 45 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 23.8% 21 / 88 CC 16 SCAR 53.4
CC
16
Cov
21%
evaluate
272.0
BEGIN
1.0
BEGIN
1.0
CRAP 207.5
« Perl/Lint/Policy/RegularExpressions/ProhibitComplexRegexes.pm ↑ Summary Perl/Lint/Policy/Variables/ProhibitLocalVars.pm »
1 package Perl::Lint::Policy::InputOutput::ProhibitReadlineInForLoop;
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 => 'Readline inside "for" loop',
9 EXPL => [211],
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=16 SCAR=56.1
Pod undocumented
13 0 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 0 my @violations;
16 0 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
17 0 my $token_type = $token->{type};
18  
19 0 ▶ if ($token_type == FOR_STATEMENT || $token_type == FOREACH_STATEMENT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 133 or $token_type == 134) 0 0 0
Condition0%0/3
$token_type == 133 or $token_type == 134
l!l&&r!l&&!r
000
MC/DC0%0/2
$token_type == 133 or $token_type == 134
$token_type == 133 $token_type == 134
Truth table0%0/3
A or B
A= $token_type == 133B= $token_type == 134
ABresult
1X1
011
000
20 0 $i++;
21 0 $token = $tokens->[$i];
22 0 $token_type = $token->{type};
23 0 ▶ if ($token_type == DIAMOND || $token_type == LESS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 32 or $token_type == 8) 0 0 0
Condition0%0/3
$token_type == 32 or $token_type == 8
l!l&&r!l&&!r
000
MC/DC0%0/2
$token_type == 32 or $token_type == 8
$token_type == 32 $token_type == 8
Truth table0%0/3
A or B
A= $token_type == 32B= $token_type == 8
ABresult
1X1
011
000
24 # ~~~~ XXX should be HandleDecl in fact
25 push @violations, {
26 filename => $file,
27 line => $token->{line},
28 0 description => DESC,
29 explanation => EXPL,
30 policy => __PACKAGE__,
31 };
32 0 next;
33 }
34  
35 0 ▶ for (; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
36 0 $token_type = $token->{type};
37 0 my $left_paren_num = 0;
38 0 ▶ if ($token_type == LEFT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 107) 0 0 0
39 0 $left_paren_num++;
40 0 ▶ for ($i++; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
41 0 $token_type = $token->{type};
42 0 ▶ if ($token_type == LEFT_PAREN) {
Branch: 4 branches
BranchTrueFalseTotal
if ($token_type == 107) { } 0 0 0
elsif ($token_type == 108) { } 0 0 0
elsif ($token_type == 32) { } 0 0 0
elsif ($token_type == 152) { } 0 0 0
43 0 $left_paren_num++;
44 }
45 elsif ($token_type == RIGHT_PAREN) {
46 0 ▶ last if --$left_paren_num <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if --$left_paren_num <= 0 0 0 0
47 }
48 elsif ($token_type == DIAMOND) {
49 push @violations, {
50 filename => $file,
51 line => $token->{line},
52 0 description => DESC,
53 explanation => EXPL,
54 policy => __PACKAGE__,
55 };
56 }
57 elsif ($token_type == HANDLE_DELIM) {
58 0 ▶ for ($i++; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
59 0 $token_type = $token->{type};
60 0 ▶ if ($token_type == HANDLE_DELIM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 152) 0 0 0
61 push @violations, {
62 filename => $file,
63 line => $token->{line},
64 0 description => DESC,
65 explanation => EXPL,
66 policy => __PACKAGE__,
67 };
68 0 last;
69 }
70 }
71 }
72 }
73 0 last;
74 }
75 }
76 }
77 }
78  
79 0 return \@violations;
80 }
81  
82 2 1;
83  
« Perl/Lint/Policy/RegularExpressions/ProhibitComplexRegexes.pm ↑ Summary Perl/Lint/Policy/Variables/ProhibitLocalVars.pm »