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