line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::Modules::ProhibitMultiplePackages; |
2
|
133
|
|
|
133
|
|
68216
|
use strict; |
|
133
|
|
|
|
|
183
|
|
|
133
|
|
|
|
|
3082
|
|
3
|
133
|
|
|
133
|
|
404
|
use warnings; |
|
133
|
|
|
|
|
163
|
|
|
133
|
|
|
|
|
3213
|
|
4
|
133
|
|
|
133
|
|
769
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
148
|
|
|
133
|
|
|
|
|
60244
|
|
5
|
133
|
|
|
133
|
|
601
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
166
|
|
|
133
|
|
|
|
|
551
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
23746
|
DESC => 'Multiple "package" declarations', |
9
|
|
|
|
|
|
|
EXPL => 'Limit to one per file', |
10
|
133
|
|
|
133
|
|
7045
|
}; |
|
133
|
|
|
|
|
170
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
4
|
|
|
4
|
0
|
5
|
my ($class, $file, $tokens, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
5
|
my @violations; |
16
|
4
|
|
|
|
|
4
|
my $had_declared_package = 0; |
17
|
4
|
|
|
|
|
13
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
18
|
37
|
|
|
|
|
26
|
my $token_type = $token->{type}; |
19
|
37
|
100
|
|
|
|
64
|
if ($token_type == PACKAGE) { |
20
|
7
|
100
|
|
|
|
24
|
unless ($had_declared_package) { |
21
|
3
|
|
|
|
|
3
|
$had_declared_package = 1; |
22
|
3
|
|
|
|
|
9
|
next; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
push @violations, { |
26
|
|
|
|
|
|
|
filename => $file, |
27
|
|
|
|
|
|
|
line => $token->{line}, |
28
|
4
|
|
|
|
|
18
|
description => DESC, |
29
|
|
|
|
|
|
|
explanation => EXPL, |
30
|
|
|
|
|
|
|
policy => __PACKAGE__, |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
|
|
13
|
return \@violations; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|