line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::TestingAndDebugging::ProhibitNoStrict; |
2
|
133
|
|
|
133
|
|
67232
|
use strict; |
|
133
|
|
|
|
|
171
|
|
|
133
|
|
|
|
|
3035
|
|
3
|
133
|
|
|
133
|
|
375
|
use warnings; |
|
133
|
|
|
|
|
149
|
|
|
133
|
|
|
|
|
2351
|
|
4
|
133
|
|
|
133
|
|
841
|
use utf8; |
|
133
|
|
|
|
|
198
|
|
|
133
|
|
|
|
|
540
|
|
5
|
133
|
|
|
133
|
|
2525
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
147
|
|
|
133
|
|
|
|
|
59311
|
|
6
|
133
|
|
|
133
|
|
544
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
151
|
|
|
133
|
|
|
|
|
537
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant { |
9
|
133
|
|
|
|
|
43682
|
DESC => 'Stricture disabled', |
10
|
|
|
|
|
|
|
EXPL => [429], |
11
|
133
|
|
|
133
|
|
6788
|
}; |
|
133
|
|
|
|
|
179
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub evaluate { |
14
|
10
|
|
|
10
|
0
|
19
|
my ($class, $file, $tokens, $src, $args) = @_; |
15
|
|
|
|
|
|
|
|
16
|
10
|
|
|
|
|
10
|
my @arg_allows; |
17
|
10
|
100
|
|
|
|
29
|
if (my $this_policies_arg = $args->{prohibit_no_strict}) { |
18
|
6
|
50
|
|
|
|
26
|
if (my $allow = $this_policies_arg->{allow}) { |
19
|
6
|
|
|
|
|
28
|
@arg_allows = map { lc $_ } split(/[\s,]/, $allow); |
|
12
|
|
|
|
|
26
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
10
|
|
|
|
|
8
|
my @violations; |
24
|
10
|
|
|
|
|
12
|
my $token_num = scalar @$tokens; |
25
|
10
|
|
|
|
|
26
|
for (my $i = 0; $i < $token_num; $i++) { |
26
|
40
|
|
|
|
|
36
|
my $token = $tokens->[$i]; |
27
|
40
|
|
|
|
|
37
|
my $token_type = $token->{type}; |
28
|
|
|
|
|
|
|
|
29
|
40
|
100
|
66
|
|
|
101
|
if ($token_type == BUILTIN_FUNC and $token->{data} eq 'no') { |
30
|
10
|
|
|
|
|
14
|
$token = $tokens->[++$i]; |
31
|
|
|
|
|
|
|
|
32
|
10
|
|
|
|
|
11
|
my @allows; |
33
|
10
|
50
|
33
|
|
|
34
|
if ($token->{type} == KEY && $token->{data} eq 'strict') { |
34
|
10
|
|
|
|
|
21
|
for ($i++; $i < $token_num; $i++) { |
35
|
43
|
|
|
|
|
34
|
$token = $tokens->[$i]; |
36
|
43
|
|
|
|
|
30
|
$token_type = $token->{type}; |
37
|
|
|
|
|
|
|
|
38
|
43
|
100
|
100
|
|
|
191
|
if ($token_type == STRING || $token_type == RAW_STRING) { |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
39
|
13
|
|
|
|
|
27
|
push @allows, $token->{data}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
elsif ($token_type == REG_EXP) { |
42
|
3
|
|
|
|
|
13
|
push @allows, split(/ /, $token->{data}); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
elsif ($token_type == SEMI_COLON || !$tokens->[$i+1]) { |
45
|
10
|
|
|
|
|
16
|
for my $arg_allow (@arg_allows) { |
46
|
12
|
|
|
|
|
14
|
@allows = grep { $_ ne $arg_allow } @allows; |
|
25
|
|
|
|
|
39
|
|
47
|
|
|
|
|
|
|
} |
48
|
10
|
100
|
100
|
|
|
38
|
if (!@arg_allows || @allows) { |
49
|
|
|
|
|
|
|
push @violations, { |
50
|
|
|
|
|
|
|
filename => $file, |
51
|
|
|
|
|
|
|
line => $token->{line}, |
52
|
7
|
|
|
|
|
32
|
description => DESC, |
53
|
|
|
|
|
|
|
explanation => EXPL, |
54
|
|
|
|
|
|
|
policy => __PACKAGE__, |
55
|
|
|
|
|
|
|
}; |
56
|
7
|
|
|
|
|
21
|
last; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
10
|
|
|
|
|
36
|
return \@violations; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|