line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::TestingAndDebugging::ProhibitNoWarnings; |
2
|
133
|
|
|
133
|
|
67953
|
use strict; |
|
133
|
|
|
|
|
170
|
|
|
133
|
|
|
|
|
3021
|
|
3
|
133
|
|
|
133
|
|
390
|
use warnings; |
|
133
|
|
|
|
|
131
|
|
|
133
|
|
|
|
|
2324
|
|
4
|
133
|
|
|
133
|
|
757
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
127
|
|
|
133
|
|
|
|
|
59352
|
|
5
|
133
|
|
|
133
|
|
523
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
147
|
|
|
133
|
|
|
|
|
551
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
45382
|
DESC => 'Warnings disabled', |
9
|
|
|
|
|
|
|
EXPL => [431], |
10
|
133
|
|
|
133
|
|
6865
|
}; |
|
133
|
|
|
|
|
154
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
13
|
|
|
13
|
0
|
24
|
my ($class, $file, $tokens, $src, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
13
|
|
|
|
|
15
|
my @arg_allows; |
16
|
|
|
|
|
|
|
my $allow_with_category_restriction; |
17
|
13
|
100
|
|
|
|
39
|
if (my $this_policies_arg = $args->{prohibit_no_warnings}) { |
18
|
10
|
100
|
|
|
|
31
|
if (my $allow = $this_policies_arg->{allow}) { |
19
|
4
|
|
|
|
|
17
|
@arg_allows = map { lc $_ } split(/[\s,]/, $allow); |
|
9
|
|
|
|
|
18
|
|
20
|
|
|
|
|
|
|
} |
21
|
10
|
|
|
|
|
17
|
$allow_with_category_restriction = $this_policies_arg->{allow_with_category_restriction}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
13
|
|
|
|
|
17
|
my @violations; |
25
|
13
|
|
|
|
|
13
|
my $token_num = scalar @$tokens; |
26
|
13
|
|
|
|
|
38
|
for (my $i = 0; $i < $token_num; $i++) { |
27
|
50
|
|
|
|
|
44
|
my $token = $tokens->[$i]; |
28
|
50
|
|
|
|
|
40
|
my $token_type = $token->{type}; |
29
|
|
|
|
|
|
|
|
30
|
50
|
100
|
66
|
|
|
143
|
if ($token_type == BUILTIN_FUNC and $token->{data} eq 'no') { |
31
|
14
|
|
|
|
|
21
|
$token = $tokens->[++$i]; |
32
|
|
|
|
|
|
|
|
33
|
14
|
|
|
|
|
22
|
my @allows; |
34
|
14
|
50
|
33
|
|
|
60
|
if ($token->{type} == KEY && $token->{data} eq 'warnings') { |
35
|
14
|
|
|
|
|
29
|
for ($i++; $i < $token_num; $i++) { |
36
|
53
|
|
|
|
|
44
|
$token = $tokens->[$i]; |
37
|
53
|
|
|
|
|
39
|
$token_type = $token->{type}; |
38
|
|
|
|
|
|
|
|
39
|
53
|
100
|
100
|
|
|
261
|
if ($token_type == STRING || $token_type == RAW_STRING) { |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
40
|
13
|
|
|
|
|
42
|
push @allows, $token->{data}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ($token_type == REG_EXP) { |
43
|
4
|
|
|
|
|
34
|
push @allows, split(/ /, $token->{data}); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
elsif ($token_type == SEMI_COLON || !$tokens->[$i+1]) { |
46
|
14
|
100
|
100
|
|
|
63
|
last if @allows && $allow_with_category_restriction; |
47
|
|
|
|
|
|
|
|
48
|
9
|
|
|
|
|
13
|
for my $arg_allow (@arg_allows) { |
49
|
9
|
|
|
|
|
10
|
@allows = grep { $_ ne $arg_allow } @allows; |
|
19
|
|
|
|
|
30
|
|
50
|
|
|
|
|
|
|
} |
51
|
9
|
100
|
100
|
|
|
32
|
if (!@arg_allows || @allows) { |
52
|
|
|
|
|
|
|
push @violations, { |
53
|
|
|
|
|
|
|
filename => $file, |
54
|
|
|
|
|
|
|
line => $token->{line}, |
55
|
7
|
|
|
|
|
31
|
description => DESC, |
56
|
|
|
|
|
|
|
explanation => EXPL, |
57
|
|
|
|
|
|
|
policy => __PACKAGE__, |
58
|
|
|
|
|
|
|
}; |
59
|
7
|
|
|
|
|
21
|
last; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
13
|
|
|
|
|
45
|
return \@violations; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|