blib/lib/Perl/Lint/Policy/TestingAndDebugging/ProhibitNoWarnings.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 SCAR 0.1
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Perl/Lint/Policy/Subroutines/RequireFinalReturn.pm ↑ Summary blib/lib/Perl/Lint/Policy/ValuesAndExpressions/ProhibitCommaSeparatedStatements.pm »
1 package Perl::Lint::Policy::TestingAndDebugging::ProhibitNoWarnings;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Perl::Lint::Constants::Type;
Subroutine BEGIN: called CC=1 SCAR=2.6
5 use parent "Perl::Lint::Policy";
6  
7 use constant {
8 DESC => 'Warnings disabled',
9 EXPL => [431],
10 };
11  
12 sub evaluate {
13 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 my @arg_allows;
16 my $allow_with_category_restriction;
17 if (my $this_policies_arg = $args->{prohibit_no_warnings}) {
18 if (my $allow = $this_policies_arg->{allow}) {
19 @arg_allows = map { lc $_ } split(/[\s,]/, $allow);
20 }
21 $allow_with_category_restriction = $this_policies_arg->{allow_with_category_restriction};
22 }
23  
24 my @violations;
25 my $token_num = scalar @$tokens;
26 for (my $i = 0; $i < $token_num; $i++) {
27 my $token = $tokens->[$i];
28 my $token_type = $token->{type};
29  
30 if ($token_type == BUILTIN_FUNC and $token->{data} eq 'no') {
31 $token = $tokens->[++$i];
32  
33 my @allows;
34 if ($token->{type} == KEY && $token->{data} eq 'warnings') {
35 for ($i++; $i < $token_num; $i++) {
36 $token = $tokens->[$i];
37 $token_type = $token->{type};
38  
39 if ($token_type == STRING || $token_type == RAW_STRING) {
40 push @allows, $token->{data};
41 }
42 elsif ($token_type == REG_EXP) {
43 push @allows, split(/ /, $token->{data});
44 }
45 elsif ($token_type == SEMI_COLON || !$tokens->[$i+1]) {
46 last if @allows && $allow_with_category_restriction;
47  
48 for my $arg_allow (@arg_allows) {
49 @allows = grep { $_ ne $arg_allow } @allows;
50 }
51 if (!@arg_allows || @allows) {
52 push @violations, {
53 filename => $file,
54 line => $token->{line},
55 description => DESC,
56 explanation => EXPL,
57 policy => __PACKAGE__,
58 };
59 last;
60 }
61 }
62 }
63 }
64 }
65 }
66  
67 return \@violations;
68 }
69  
70 1;
71  
« blib/lib/Perl/Lint/Policy/Subroutines/RequireFinalReturn.pm ↑ Summary blib/lib/Perl/Lint/Policy/ValuesAndExpressions/ProhibitCommaSeparatedStatements.pm »