line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::TestingAndDebugging::ProhibitNoWarnings; |
2
|
133
|
|
|
133
|
|
101176
|
use strict; |
|
133
|
|
|
|
|
255
|
|
|
133
|
|
|
|
|
4851
|
|
3
|
133
|
|
|
133
|
|
593
|
use warnings; |
|
133
|
|
|
|
|
208
|
|
|
133
|
|
|
|
|
4004
|
|
4
|
133
|
|
|
133
|
|
1104
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
186
|
|
|
133
|
|
|
|
|
83737
|
|
5
|
133
|
|
|
133
|
|
785
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
209
|
|
|
133
|
|
|
|
|
780
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
56682
|
DESC => 'Warnings disabled', |
9
|
|
|
|
|
|
|
EXPL => [431], |
10
|
133
|
|
|
133
|
|
8921
|
}; |
|
133
|
|
|
|
|
235
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
13
|
|
|
13
|
0
|
53
|
my ($class, $file, $tokens, $src, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
13
|
|
|
|
|
23
|
my @arg_allows; |
16
|
|
|
|
|
|
|
my $allow_with_category_restriction; |
17
|
13
|
100
|
|
|
|
72
|
if (my $this_policies_arg = $args->{prohibit_no_warnings}) { |
18
|
10
|
100
|
|
|
|
113
|
if (my $allow = $this_policies_arg->{allow}) { |
19
|
4
|
|
|
|
|
40
|
@arg_allows = map { lc $_ } split(/[\s,]/, $allow); |
|
9
|
|
|
|
|
51
|
|
20
|
|
|
|
|
|
|
} |
21
|
10
|
|
|
|
|
42
|
$allow_with_category_restriction = $this_policies_arg->{allow_with_category_restriction}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
13
|
|
|
|
|
32
|
my @violations; |
25
|
13
|
|
|
|
|
39
|
my $token_num = scalar @$tokens; |
26
|
13
|
|
|
|
|
81
|
for (my $i = 0; $i < $token_num; $i++) { |
27
|
50
|
|
|
|
|
76
|
my $token = $tokens->[$i]; |
28
|
50
|
|
|
|
|
92
|
my $token_type = $token->{type}; |
29
|
|
|
|
|
|
|
|
30
|
50
|
100
|
66
|
|
|
244
|
if ($token_type == BUILTIN_FUNC and $token->{data} eq 'no') { |
31
|
14
|
|
|
|
|
37
|
$token = $tokens->[++$i]; |
32
|
|
|
|
|
|
|
|
33
|
14
|
|
|
|
|
22
|
my @allows; |
34
|
14
|
50
|
33
|
|
|
111
|
if ($token->{type} == KEY && $token->{data} eq 'warnings') { |
35
|
14
|
|
|
|
|
62
|
for ($i++; $i < $token_num; $i++) { |
36
|
53
|
|
|
|
|
73
|
$token = $tokens->[$i]; |
37
|
53
|
|
|
|
|
73
|
$token_type = $token->{type}; |
38
|
|
|
|
|
|
|
|
39
|
53
|
100
|
100
|
|
|
472
|
if ($token_type == STRING || $token_type == RAW_STRING) { |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
|
|
|
|
|
40
|
13
|
|
|
|
|
51
|
push @allows, $token->{data}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ($token_type == REG_EXP) { |
43
|
4
|
|
|
|
|
31
|
push @allows, split(/ /, $token->{data}); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
elsif ($token_type == SEMI_COLON || !$tokens->[$i+1]) { |
46
|
14
|
100
|
100
|
|
|
102
|
last if @allows && $allow_with_category_restriction; |
47
|
|
|
|
|
|
|
|
48
|
9
|
|
|
|
|
32
|
for my $arg_allow (@arg_allows) { |
49
|
9
|
|
|
|
|
17
|
@allows = grep { $_ ne $arg_allow } @allows; |
|
19
|
|
|
|
|
63
|
|
50
|
|
|
|
|
|
|
} |
51
|
9
|
100
|
100
|
|
|
80
|
if (!@arg_allows || @allows) { |
52
|
7
|
|
|
|
|
71
|
push @violations, { |
53
|
|
|
|
|
|
|
filename => $file, |
54
|
|
|
|
|
|
|
line => $token->{line}, |
55
|
|
|
|
|
|
|
description => DESC, |
56
|
|
|
|
|
|
|
explanation => EXPL, |
57
|
|
|
|
|
|
|
policy => __PACKAGE__, |
58
|
|
|
|
|
|
|
}; |
59
|
7
|
|
|
|
|
48
|
last; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
13
|
|
|
|
|
98
|
return \@violations; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|