line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::Modules::RequireVersionVar; |
2
|
133
|
|
|
133
|
|
67569
|
use strict; |
|
133
|
|
|
|
|
170
|
|
|
133
|
|
|
|
|
3075
|
|
3
|
133
|
|
|
133
|
|
397
|
use warnings; |
|
133
|
|
|
|
|
188
|
|
|
133
|
|
|
|
|
2393
|
|
4
|
133
|
|
|
133
|
|
746
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
139
|
|
|
133
|
|
|
|
|
58159
|
|
5
|
133
|
|
|
133
|
|
535
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
155
|
|
|
133
|
|
|
|
|
595
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
35568
|
DESC => 'No package-scoped "$VERSION" variable found', |
9
|
|
|
|
|
|
|
EXPL => [404], |
10
|
133
|
|
|
133
|
|
6735
|
}; |
|
133
|
|
|
|
|
178
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
14
|
|
|
14
|
0
|
23
|
my ($class, $file, $tokens, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
14
|
|
|
|
|
9
|
my @violations; |
16
|
14
|
|
|
|
|
13
|
my $does_exist_version_ver = 0; |
17
|
14
|
|
|
|
|
42
|
TOP: for (my $i = 0, my $next_token, my $token_type, my $token_data; my $token = $tokens->[$i]; $i++) { |
18
|
41
|
|
|
|
|
40
|
$next_token = $tokens->[$i+1]; |
19
|
41
|
|
|
|
|
33
|
$token_type = $token->{type}; |
20
|
41
|
|
|
|
|
30
|
$token_data = $token->{data}; |
21
|
|
|
|
|
|
|
|
22
|
41
|
100
|
66
|
|
|
294
|
if ($token_type == USED_NAME && $token_data eq 'vars') { |
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
23
|
2
|
100
|
66
|
|
|
11
|
if ( |
24
|
|
|
|
|
|
|
$next_token->{type} == RAW_STRING && |
25
|
|
|
|
|
|
|
$next_token->{data} eq '$VERSION' |
26
|
|
|
|
|
|
|
) { |
27
|
1
|
|
|
|
|
1
|
$does_exist_version_ver = 1; |
28
|
1
|
|
|
|
|
2
|
last; |
29
|
|
|
|
|
|
|
} |
30
|
1
|
|
|
|
|
4
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
31
|
3
|
|
|
|
|
3
|
my $token_type = $token->{type}; |
32
|
3
|
|
|
|
|
4
|
my $token_data = $token->{data}; |
33
|
3
|
50
|
|
|
|
5
|
if ($token_type == SEMI_COLON) { |
34
|
0
|
|
|
|
|
0
|
last; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
3
|
100
|
66
|
|
|
9
|
if ($token_type == REG_EXP && $token_data eq '$VERSION') { |
38
|
1
|
|
|
|
|
2
|
$does_exist_version_ver = 1; |
39
|
1
|
|
|
|
|
3
|
last TOP; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif ( |
44
|
|
|
|
|
|
|
($token_type == GLOBAL_VAR && $token_data eq '$VERSION') || |
45
|
|
|
|
|
|
|
($token_type == CLASS && $next_token->{type} == DOUBLE) || |
46
|
|
|
|
|
|
|
( |
47
|
|
|
|
|
|
|
$token_type == NAMESPACE_RESOLVER && |
48
|
|
|
|
|
|
|
$next_token->{type} == NAMESPACE && |
49
|
|
|
|
|
|
|
$next_token->{data} eq 'VERSION' |
50
|
|
|
|
|
|
|
) |
51
|
|
|
|
|
|
|
) { |
52
|
6
|
|
|
|
|
3
|
$does_exist_version_ver = 1; |
53
|
6
|
|
|
|
|
10
|
last; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
14
|
100
|
|
|
|
24
|
unless ($does_exist_version_ver) { |
58
|
6
|
|
|
|
|
24
|
push @violations, { |
59
|
|
|
|
|
|
|
filename => $file, |
60
|
|
|
|
|
|
|
line => 1, # TODO |
61
|
|
|
|
|
|
|
description => DESC, |
62
|
|
|
|
|
|
|
explanation => EXPL, |
63
|
|
|
|
|
|
|
policy => __PACKAGE__, |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
14
|
|
|
|
|
41
|
return \@violations; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|