| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::ControlStructures::ProhibitCStyleForLoops; |
|
2
|
134
|
|
|
134
|
|
70554
|
use strict; |
|
|
134
|
|
|
|
|
452
|
|
|
|
134
|
|
|
|
|
3082
|
|
|
3
|
134
|
|
|
134
|
|
425
|
use warnings; |
|
|
134
|
|
|
|
|
154
|
|
|
|
134
|
|
|
|
|
2412
|
|
|
4
|
134
|
|
|
134
|
|
827
|
use Perl::Lint::Constants::Type; |
|
|
134
|
|
|
|
|
144
|
|
|
|
134
|
|
|
|
|
60306
|
|
|
5
|
134
|
|
|
134
|
|
922
|
use Perl::Lint::Constants::Kind; |
|
|
134
|
|
|
|
|
145
|
|
|
|
134
|
|
|
|
|
6514
|
|
|
6
|
134
|
|
|
134
|
|
467
|
use parent "Perl::Lint::Policy"; |
|
|
134
|
|
|
|
|
208
|
|
|
|
134
|
|
|
|
|
540
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant { |
|
9
|
134
|
|
|
|
|
27771
|
DESC => 'C-style "for" loop used', |
|
10
|
|
|
|
|
|
|
EXPL => [100], |
|
11
|
134
|
|
|
134
|
|
6539
|
}; |
|
|
134
|
|
|
|
|
153
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub evaluate { |
|
14
|
5
|
|
|
5
|
0
|
7
|
my ($class, $file, $tokens, $src, $args) = @_; |
|
15
|
|
|
|
|
|
|
|
|
16
|
5
|
|
|
|
|
6
|
my @violations; |
|
17
|
5
|
|
|
|
|
17
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
|
18
|
114
|
|
|
|
|
69
|
my $token_type = $token->{type}; |
|
19
|
|
|
|
|
|
|
|
|
20
|
114
|
100
|
100
|
|
|
326
|
if ($token_type == FOR_STATEMENT || $token_type == FOREACH_STATEMENT) { |
|
21
|
11
|
|
|
|
|
11
|
my $token = $tokens->[++$i]; |
|
22
|
11
|
100
|
|
|
|
21
|
if ($token->{type} == LEFT_PAREN) { |
|
23
|
8
|
|
|
|
|
6
|
my $semi_colon_count = 0; |
|
24
|
8
|
|
|
|
|
7
|
my $left_paren_num = 1; |
|
25
|
8
|
|
|
|
|
16
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
|
26
|
80
|
|
|
|
|
57
|
my $token_type = $token->{type}; |
|
27
|
80
|
50
|
|
|
|
173
|
if ($token_type == LEFT_PAREN) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
$left_paren_num++; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
elsif ($token_type == RIGHT_PAREN) { |
|
31
|
8
|
50
|
|
|
|
14
|
last if --$left_paren_num <= 0; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
elsif ($token_type == SEMI_COLON) { |
|
34
|
14
|
|
|
|
|
17
|
$semi_colon_count++; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
8
|
100
|
|
|
|
13
|
if ($semi_colon_count == 2) { |
|
39
|
|
|
|
|
|
|
push @violations, { |
|
40
|
|
|
|
|
|
|
filename => $file, |
|
41
|
|
|
|
|
|
|
line => $token->{line}, |
|
42
|
7
|
|
|
|
|
49
|
description => DESC, |
|
43
|
|
|
|
|
|
|
explanation => EXPL, |
|
44
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
45
|
|
|
|
|
|
|
}; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
5
|
|
|
|
|
15
|
return \@violations; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
|
55
|
|
|
|
|
|
|
|