Perl/Lint/Policy/TestingAndDebugging/ProhibitNoWarnings.pm

filter: Statementstmt 34.7% 16 / 46 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 20.0% 21 / 105 CC 19 SCAR 57.1
CC
19
Cov
19%
evaluate
380.0
BEGIN
1.0
BEGIN
1.0
CRAP 301.0
« Perl/Lint/Policy/InputOutput/ProhibitBacktickOperators.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/ProhibitStringyEval.pm »
1 package Perl::Lint::Policy::TestingAndDebugging::ProhibitNoWarnings;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Perl::Lint::Constants::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use parent "Perl::Lint::Policy";
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 DESC => 'Warnings disabled',
9 EXPL => [431],
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=19 SCAR=59.4
Pod undocumented
13 0 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 0 my @arg_allows;
16 my $allow_with_category_restriction;
17 0 ▶ if (my $this_policies_arg = $args->{prohibit_no_warnings}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $this_policies_arg = $args->{"prohibit_no_warnings"}) 0 0 0
18 0 ▶ if (my $allow = $this_policies_arg->{allow}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $allow = $this_policies_arg->{"allow"}) 0 0 0
19 0 @arg_allows = map { lc $_ } split(/[\s,]/, $allow);
20 }
21 0 $allow_with_category_restriction = $this_policies_arg->{allow_with_category_restriction};
22 }
23  
24 0 my @violations;
25 0 my $token_num = scalar @$tokens;
26 0 ▶ for (my $i = 0; $i < $token_num; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $token_num) 0 0 0
27 0 my $token = $tokens->[$i];
28 0 my $token_type = $token->{type};
29  
30 0 ▶ if ($token_type == BUILTIN_FUNC and $token->{data} eq 'no') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 70 and $token->{"data"} eq "no") 0 0 0
Condition0%0/3
$token_type == 70 and $token->{"data"} eq "no"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 70 and $token->{"data"} eq "no"
$token_type == 70 $token->{"data"} eq "no"
Truth table0%0/3
A and B
A= $token_type == 70B= $token->{"data"} eq "no"
ABresult
0X0
100
111
31 0 $token = $tokens->[++$i];
32  
33 0 my @allows;
34 0 ▶ if ($token->{type} == KEY && $token->{data} eq 'warnings') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 122 and $token->{"data"} eq "warnings") 0 0 0
Condition0%0/3
$token->{"type"} == 122 and $token->{"data"} eq "warnings"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->{"type"} == 122 and $token->{"data"} eq "warnings"
$token->{"type"} == 122 $token->{"data"} eq "warnings"
Truth table0%0/3
A and B
A= $token->{"type"} == 122B= $token->{"data"} eq "warnings"
ABresult
0X0
100
111
35 0 ▶ for ($i++; $i < $token_num; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $token_num) 0 0 0
36 0 $token = $tokens->[$i];
37 0 $token_type = $token->{type};
38  
39 0 ▶ if ($token_type == STRING || $token_type == RAW_STRING) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token_type == 172 or $token_type == 173) { } 0 0 0
elsif ($token_type == 187) { } 0 0 0
elsif ($token_type == 106 or not $$tokens[$i + 1]) { } 0 0 0
Condition0%0/3
$token_type == 172 or $token_type == 173
l!l&&r!l&&!r
000
MC/DC0%0/2
$token_type == 172 or $token_type == 173
$token_type == 172 $token_type == 173
Truth table0%0/3
A or B
A= $token_type == 172B= $token_type == 173
ABresult
1X1
011
000
40 0 push @allows, $token->{data};
41 }
42 elsif ($token_type == REG_EXP) {
43 0 push @allows, split(/ /, $token->{data});
44 }
45 ▶ elsif ($token_type == SEMI_COLON || !$tokens->[$i+1]) {
Condition0%0/3
$token_type == 106 or not $$tokens[$i + 1]
l!l&&r!l&&!r
000
MC/DC0%0/2
$token_type == 106 or not $$tokens[$i + 1]
$token_type == 106 not $$tokens[$i + 1]
Truth table0%0/3
A or not(B)
A= $token_type == 106B= not $$tokens[$i + 1]
ABresult
1X1
011
000
46 0 ▶ last if @allows && $allow_with_category_restriction;
Branch: 1 branch
BranchTrueFalseTotal
if @allows and $allow_with_category_restriction 0 0 0
Condition0%0/3
@allows and $allow_with_category_restriction
!ll&&!rl&&r
000
MC/DC0%0/2
@allows and $allow_with_category_restriction
@allows $allow_with_category_restriction
Truth table0%0/3
A and B
A= @allowsB= $allow_with_category_restriction
ABresult
0X0
100
111
47  
48 0 for my $arg_allow (@arg_allows) {
49 0 @allows = grep { $_ ne $arg_allow } @allows;
50 }
51 0 ▶ if (!@arg_allows || @allows) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @arg_allows or @allows) 0 0 0
Condition0%0/3
not @arg_allows or @allows
l!l&&r!l&&!r
000
MC/DC0%0/2
not @arg_allows or @allows
not @arg_allows @allows
Truth table0%0/3
not(A) or B
A= not @arg_allowsB= @allows
ABresult
1X1
011
000
52 push @violations, {
53 filename => $file,
54 line => $token->{line},
55 0 description => DESC,
56 explanation => EXPL,
57 policy => __PACKAGE__,
58 };
59 0 last;
60 }
61 }
62 }
63 }
64 }
65 }
66  
67 0 return \@violations;
68 }
69  
70 2 1;
71  
« Perl/Lint/Policy/InputOutput/ProhibitBacktickOperators.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/ProhibitStringyEval.pm »