line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::Modules::RequireBarewordIncludes; |
2
|
133
|
|
|
133
|
|
67461
|
use strict; |
|
133
|
|
|
|
|
164
|
|
|
133
|
|
|
|
|
2980
|
|
3
|
133
|
|
|
133
|
|
402
|
use warnings; |
|
133
|
|
|
|
|
140
|
|
|
133
|
|
|
|
|
2481
|
|
4
|
133
|
|
|
133
|
|
759
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
142
|
|
|
133
|
|
|
|
|
58377
|
|
5
|
133
|
|
|
133
|
|
531
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
169
|
|
|
133
|
|
|
|
|
1891
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
25208
|
DESC => '"%s" statement with library name as string', |
9
|
|
|
|
|
|
|
EXPL => 'Use a bareword instead', |
10
|
133
|
|
|
133
|
|
6519
|
}; |
|
133
|
|
|
|
|
149
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
4
|
|
|
4
|
0
|
8
|
my ($class, $file, $tokens, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
1
|
my @violations; |
16
|
|
|
|
|
|
|
my $next_token; |
17
|
4
|
|
|
|
|
16
|
for (my $i = 0, my $next_token, my $next_token_type; my $token = $tokens->[$i]; $i++) { |
18
|
93
|
|
|
|
|
66
|
my $token_type = $token->{type}; |
19
|
93
|
|
|
|
|
73
|
my $token_data = $token->{data}; |
20
|
|
|
|
|
|
|
|
21
|
93
|
|
|
|
|
70
|
$next_token = $tokens->[$i+1]; |
22
|
93
|
|
|
|
|
59
|
$next_token_type = $next_token->{type}; |
23
|
93
|
100
|
66
|
|
|
465
|
if ( |
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
24
|
|
|
|
|
|
|
$next_token_type && |
25
|
|
|
|
|
|
|
( |
26
|
|
|
|
|
|
|
$token_type == USE_DECL || |
27
|
|
|
|
|
|
|
$token_type == REQUIRE_DECL || |
28
|
|
|
|
|
|
|
($token_type == BUILTIN_FUNC && $token_data eq 'no') |
29
|
|
|
|
|
|
|
) && |
30
|
|
|
|
|
|
|
( |
31
|
|
|
|
|
|
|
$next_token_type == STRING || |
32
|
|
|
|
|
|
|
$next_token_type == RAW_STRING || |
33
|
|
|
|
|
|
|
$next_token_type == REG_QUOTE || |
34
|
|
|
|
|
|
|
$next_token_type == REG_DOUBLE_QUOTE |
35
|
|
|
|
|
|
|
) |
36
|
|
|
|
|
|
|
) { |
37
|
|
|
|
|
|
|
push @violations, { |
38
|
|
|
|
|
|
|
filename => $file, |
39
|
|
|
|
|
|
|
line => $token->{line}, |
40
|
12
|
|
|
|
|
54
|
description => sprintf(DESC, $token_data), |
41
|
|
|
|
|
|
|
explanation => EXPL, |
42
|
|
|
|
|
|
|
policy => __PACKAGE__, |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
|
|
16
|
return \@violations; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|