| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::Variables::RequireInitializationForLocalVars; |
|
2
|
133
|
|
|
133
|
|
77705
|
use strict; |
|
|
133
|
|
|
|
|
173
|
|
|
|
133
|
|
|
|
|
3162
|
|
|
3
|
133
|
|
|
133
|
|
422
|
use warnings; |
|
|
133
|
|
|
|
|
150
|
|
|
|
133
|
|
|
|
|
2562
|
|
|
4
|
133
|
|
|
133
|
|
760
|
use Perl::Lint::Constants::Type; |
|
|
133
|
|
|
|
|
144
|
|
|
|
133
|
|
|
|
|
59909
|
|
|
5
|
133
|
|
|
133
|
|
610
|
use parent "Perl::Lint::Policy"; |
|
|
133
|
|
|
|
|
149
|
|
|
|
133
|
|
|
|
|
574
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
|
8
|
133
|
|
|
|
|
27637
|
DESC => '"local" variable not initialized', |
|
9
|
|
|
|
|
|
|
EXPL => [78], |
|
10
|
133
|
|
|
133
|
|
6662
|
}; |
|
|
133
|
|
|
|
|
165
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
|
13
|
4
|
|
|
4
|
0
|
7
|
my ($class, $file, $tokens, $src, $args) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
5
|
my @violations; |
|
16
|
4
|
|
|
|
|
16
|
for (my $i = 0, my $token_type; my $token = $tokens->[$i]; $i++) { |
|
17
|
49
|
|
|
|
|
37
|
$token_type = $token->{type}; |
|
18
|
|
|
|
|
|
|
|
|
19
|
49
|
100
|
|
|
|
74
|
if ($token_type == LOCAL_DECL) { |
|
20
|
15
|
|
|
|
|
12
|
$token = $tokens->[++$i]; |
|
21
|
15
|
|
|
|
|
11
|
$token_type = $token->{type}; |
|
22
|
|
|
|
|
|
|
|
|
23
|
15
|
100
|
|
|
|
20
|
if ($token_type == LEFT_PAREN) { |
|
24
|
8
|
|
|
|
|
6
|
my $left_paren_num = 1; |
|
25
|
8
|
|
|
|
|
12
|
for ($i++; $token = $tokens->[$i]; $i++) { |
|
26
|
32
|
|
|
|
|
25
|
$token_type = $token->{type}; |
|
27
|
|
|
|
|
|
|
|
|
28
|
32
|
50
|
|
|
|
61
|
if ($token_type == LEFT_PAREN) { |
|
|
|
100
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
$left_paren_num++; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
elsif ($token_type == RIGHT_PAREN) { |
|
32
|
8
|
50
|
|
|
|
16
|
last if --$left_paren_num <= 0; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
15
|
|
|
|
|
12
|
$token = $tokens->[++$i]; |
|
38
|
15
|
|
|
|
|
14
|
$token_type = $token->{type}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
15
|
100
|
|
|
|
22
|
if ($token_type != ASSIGN) { |
|
41
|
|
|
|
|
|
|
push @violations, { |
|
42
|
|
|
|
|
|
|
filename => $file, |
|
43
|
|
|
|
|
|
|
line => $token->{line}, |
|
44
|
12
|
|
|
|
|
50
|
description => DESC, |
|
45
|
|
|
|
|
|
|
explanation => EXPL, |
|
46
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
47
|
|
|
|
|
|
|
}; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
4
|
|
|
|
|
14
|
return \@violations; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
|
56
|
|
|
|
|
|
|
|