line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::Variables::RequireInitializationForLocalVars; |
2
|
133
|
|
|
133
|
|
119821
|
use strict; |
|
133
|
|
|
|
|
267
|
|
|
133
|
|
|
|
|
5664
|
|
3
|
133
|
|
|
133
|
|
674
|
use warnings; |
|
133
|
|
|
|
|
195
|
|
|
133
|
|
|
|
|
4166
|
|
4
|
133
|
|
|
133
|
|
1129
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
204
|
|
|
133
|
|
|
|
|
87066
|
|
5
|
133
|
|
|
133
|
|
776
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
239
|
|
|
133
|
|
|
|
|
892
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
36026
|
DESC => '"local" variable not initialized', |
9
|
|
|
|
|
|
|
EXPL => [78], |
10
|
133
|
|
|
133
|
|
9310
|
}; |
|
133
|
|
|
|
|
218
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
4
|
|
|
4
|
0
|
8
|
my ($class, $file, $tokens, $src, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
5
|
my @violations; |
16
|
4
|
|
|
|
|
14
|
for (my $i = 0, my $token_type; my $token = $tokens->[$i]; $i++) { |
17
|
49
|
|
|
|
|
40
|
$token_type = $token->{type}; |
18
|
|
|
|
|
|
|
|
19
|
49
|
100
|
|
|
|
87
|
if ($token_type == LOCAL_DECL) { |
20
|
15
|
|
|
|
|
14
|
$token = $tokens->[++$i]; |
21
|
15
|
|
|
|
|
15
|
$token_type = $token->{type}; |
22
|
|
|
|
|
|
|
|
23
|
15
|
100
|
|
|
|
20
|
if ($token_type == LEFT_PAREN) { |
24
|
8
|
|
|
|
|
8
|
my $left_paren_num = 1; |
25
|
8
|
|
|
|
|
14
|
for ($i++; $token = $tokens->[$i]; $i++) { |
26
|
32
|
|
|
|
|
26
|
$token_type = $token->{type}; |
27
|
|
|
|
|
|
|
|
28
|
32
|
50
|
|
|
|
69
|
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
|
|
|
|
|
12
|
$token = $tokens->[++$i]; |
38
|
15
|
|
|
|
|
16
|
$token_type = $token->{type}; |
39
|
|
|
|
|
|
|
|
40
|
15
|
100
|
|
|
|
22
|
if ($token_type != ASSIGN) { |
41
|
12
|
|
|
|
|
44
|
push @violations, { |
42
|
|
|
|
|
|
|
filename => $file, |
43
|
|
|
|
|
|
|
line => $token->{line}, |
44
|
|
|
|
|
|
|
description => DESC, |
45
|
|
|
|
|
|
|
explanation => EXPL, |
46
|
|
|
|
|
|
|
policy => __PACKAGE__, |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
4
|
|
|
|
|
20
|
return \@violations; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|