| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::InputOutput::ProhibitReadlineInForLoop; |
|
2
|
133
|
|
|
133
|
|
70525
|
use strict; |
|
|
133
|
|
|
|
|
195
|
|
|
|
133
|
|
|
|
|
3332
|
|
|
3
|
133
|
|
|
133
|
|
452
|
use warnings; |
|
|
133
|
|
|
|
|
189
|
|
|
|
133
|
|
|
|
|
2602
|
|
|
4
|
133
|
|
|
133
|
|
771
|
use Perl::Lint::Constants::Type; |
|
|
133
|
|
|
|
|
163
|
|
|
|
133
|
|
|
|
|
62632
|
|
|
5
|
133
|
|
|
133
|
|
624
|
use parent "Perl::Lint::Policy"; |
|
|
133
|
|
|
|
|
193
|
|
|
|
133
|
|
|
|
|
627
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
|
8
|
133
|
|
|
|
|
39454
|
DESC => 'Readline inside "for" loop', |
|
9
|
|
|
|
|
|
|
EXPL => [211], |
|
10
|
133
|
|
|
133
|
|
7131
|
}; |
|
|
133
|
|
|
|
|
203
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
|
13
|
3
|
|
|
3
|
0
|
5
|
my ($class, $file, $tokens, $src, $args) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
3
|
|
|
|
|
4
|
my @violations; |
|
16
|
3
|
|
|
|
|
11
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
|
17
|
79
|
|
|
|
|
52
|
my $token_type = $token->{type}; |
|
18
|
|
|
|
|
|
|
|
|
19
|
79
|
100
|
100
|
|
|
213
|
if ($token_type == FOR_STATEMENT || $token_type == FOREACH_STATEMENT) { |
|
20
|
18
|
|
|
|
|
10
|
$i++; |
|
21
|
18
|
|
|
|
|
11
|
$token = $tokens->[$i]; |
|
22
|
18
|
|
|
|
|
15
|
$token_type = $token->{type}; |
|
23
|
18
|
100
|
100
|
|
|
44
|
if ($token_type == DIAMOND || $token_type == LESS) { |
|
24
|
|
|
|
|
|
|
# ~~~~ XXX should be HandleDecl in fact |
|
25
|
|
|
|
|
|
|
push @violations, { |
|
26
|
|
|
|
|
|
|
filename => $file, |
|
27
|
|
|
|
|
|
|
line => $token->{line}, |
|
28
|
8
|
|
|
|
|
15
|
description => DESC, |
|
29
|
|
|
|
|
|
|
explanation => EXPL, |
|
30
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
31
|
|
|
|
|
|
|
}; |
|
32
|
8
|
|
|
|
|
14
|
next; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
10
|
|
|
|
|
16
|
for (; my $token = $tokens->[$i]; $i++) { |
|
36
|
21
|
|
|
|
|
14
|
$token_type = $token->{type}; |
|
37
|
21
|
|
|
|
|
15
|
my $left_paren_num = 0; |
|
38
|
21
|
100
|
|
|
|
34
|
if ($token_type == LEFT_PAREN) { |
|
39
|
10
|
|
|
|
|
3
|
$left_paren_num++; |
|
40
|
10
|
|
|
|
|
15
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
|
41
|
20
|
|
|
|
|
14
|
$token_type = $token->{type}; |
|
42
|
20
|
50
|
|
|
|
39
|
if ($token_type == LEFT_PAREN) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
$left_paren_num++; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
elsif ($token_type == RIGHT_PAREN) { |
|
46
|
10
|
50
|
|
|
|
16
|
last if --$left_paren_num <= 0; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
elsif ($token_type == DIAMOND) { |
|
49
|
|
|
|
|
|
|
push @violations, { |
|
50
|
|
|
|
|
|
|
filename => $file, |
|
51
|
|
|
|
|
|
|
line => $token->{line}, |
|
52
|
3
|
|
|
|
|
9
|
description => DESC, |
|
53
|
|
|
|
|
|
|
explanation => EXPL, |
|
54
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
55
|
|
|
|
|
|
|
}; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
elsif ($token_type == HANDLE_DELIM) { |
|
58
|
6
|
|
|
|
|
9
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
|
59
|
12
|
|
|
|
|
12
|
$token_type = $token->{type}; |
|
60
|
12
|
100
|
|
|
|
17
|
if ($token_type == HANDLE_DELIM) { |
|
61
|
|
|
|
|
|
|
push @violations, { |
|
62
|
|
|
|
|
|
|
filename => $file, |
|
63
|
|
|
|
|
|
|
line => $token->{line}, |
|
64
|
6
|
|
|
|
|
17
|
description => DESC, |
|
65
|
|
|
|
|
|
|
explanation => EXPL, |
|
66
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
67
|
|
|
|
|
|
|
}; |
|
68
|
6
|
|
|
|
|
11
|
last; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
} |
|
73
|
10
|
|
|
|
|
15
|
last; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
3
|
|
|
|
|
8
|
return \@violations; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
|
83
|
|
|
|
|
|
|
|