Perl/Lint/Policy/TestingAndDebugging/ProhibitProlongedStrictureOverride.pm

filter: Statementstmt 32.8% 22 / 67 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 1 totaltotal 21.0% 29 / 138 CC 23 SCAR 60.5
CC
23
Cov
19%
evaluate
552.0
BEGIN
1.0
BEGIN
1.0
CRAP 423.4
« Perl/Lint/Policy/Subroutines/ProhibitReturnSort.pm ↑ Summary Perl/Lint/Policy/ClassHierarchies/ProhibitOneArgBless.pm »
1 package Perl::Lint::Policy::TestingAndDebugging::ProhibitProlongedStrictureOverride;
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 utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Perl::Lint::Constants::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use parent "Perl::Lint::Policy";
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use constant DEFAULT_ALLOW_STATEMENTS_NUM => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 DESC => q{Don't turn off strict for large blocks of code},
12 EXPL => [433],
13 2 };
14  
15 0 ▶sub evaluate {
Subroutine evaluate: not called CC=23 SCAR=63.1
Pod undocumented
16 0 my ($class, $file, $tokens, $src, $args) = @_;
17  
18 0 my $statements_arg;
19 0 ▶ if (my $this_policies_arg = $args->{prohibit_prolonged_stricture_override}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $this_policies_arg = $args->{"prohibit_prolonged_stricture_override"}) 0 0 0
20 0 $statements_arg = $this_policies_arg->{statements};
21 }
22 0 ▶ my $allow_statements_num = defined $statements_arg ? $statements_arg : DEFAULT_ALLOW_STATEMENTS_NUM;
Branch: 1 branch
BranchTrueFalseTotal
defined $statements_arg ? : 0 0 0
23  
24 0 my @violations;
25 0 my $token_num = scalar @$tokens;
26 0 my $no_strict = undef;
27 0 my $statements_num_of_after_no_strict = 0;
28 0 ▶ TOP: for (my $i = 0; $i < $token_num; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $token_num) 0 0 0
29 0 my $token = $tokens->[$i];
30 0 my $token_type = $token->{type};
31  
32 0 ▶ if ($token_type == FUNCTION_DECL) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token_type == 63) { } 0 0 0
elsif ($token_type == 70 and $token->{'data'} eq 'no') { } 0 0 0
elsif ($token_type == 106 and $no_strict) { } 0 0 0
33 0 my $no_strict = undef;
34 0 my $statements_num_of_after_no_strict = 0;
35 0 my $left_brace_num = 0;
36 0 ▶ for ($i++; $i < $token_num; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $token_num) 0 0 0
37 0 my $token = $tokens->[$i];
38 0 my $token_type = $token->{type};
39  
40 0 ▶ if ($token_type == BUILTIN_FUNC and $token->{data} eq 'no') {
Branch: 4 branches
BranchTrueFalseTotal
if ($token_type == 70 and $token->{'data'} eq 'no') { } 0 0 0
elsif ($token_type == 106 and $no_strict) { } 0 0 0
elsif ($token_type == 109) { } 0 0 0
elsif ($token_type == 110) { } 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
41 0 $token = $tokens->[++$i];
42 0 $token_type = $token->{type};
43  
44 0 my @allows;
45 0 ▶ if ($token_type == KEY && $token->{data} eq 'strict') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 122 and $token->{"data"} eq "strict") 0 0 0
Condition0%0/3
$token_type == 122 and $token->{"data"} eq "strict"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 122 and $token->{"data"} eq "strict"
$token_type == 122 $token->{"data"} eq "strict"
Truth table0%0/3
A and B
A= $token_type == 122B= $token->{"data"} eq "strict"
ABresult
0X0
100
111
46 0 $no_strict = $token;
47 0 $i++;
48 }
49 }
50 ▶ elsif ($token_type == SEMI_COLON && $no_strict) {
Condition0%0/3
$token_type == 106 and $no_strict
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 106 and $no_strict
$token_type == 106 $no_strict
Truth table0%0/3
A and B
A= $token_type == 106B= $no_strict
ABresult
0X0
100
111
51 0 $statements_num_of_after_no_strict++;
52 0 ▶ if ($statements_num_of_after_no_strict > $allow_statements_num) {
Branch: 1 branch
BranchTrueFalseTotal
if ($statements_num_of_after_no_strict > $allow_statements_num) 0 0 0
53 push @violations, {
54 filename => $file,
55 line => $no_strict->{line},
56 0 description => DESC,
57 explanation => EXPL,
58 policy => __PACKAGE__,
59 };
60 0 next TOP;
61 }
62 }
63 elsif ($token_type == LEFT_BRACE) {
64 0 $left_brace_num++;
65 }
66 elsif ($token_type == RIGHT_BRACE) {
67 0 $left_brace_num--;
68 0 ▶ if ($left_brace_num <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_brace_num <= 0) 0 0 0
69 0 last;
70 }
71 }
72 }
73 }
74 ▶ elsif ($token_type == BUILTIN_FUNC and $token->{data} eq 'no') {
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
75 0 $token = $tokens->[++$i];
76 0 $token_type = $token->{type};
77  
78 0 my @allows;
79 0 ▶ if ($token_type == KEY && $token->{data} eq 'strict') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 122 and $token->{"data"} eq "strict") 0 0 0
Condition0%0/3
$token_type == 122 and $token->{"data"} eq "strict"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 122 and $token->{"data"} eq "strict"
$token_type == 122 $token->{"data"} eq "strict"
Truth table0%0/3
A and B
A= $token_type == 122B= $token->{"data"} eq "strict"
ABresult
0X0
100
111
80 0 $no_strict = $token;
81 0 $i++;
82 }
83 }
84 ▶ elsif ($token_type == SEMI_COLON && $no_strict) {
Condition0%0/3
$token_type == 106 and $no_strict
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 106 and $no_strict
$token_type == 106 $no_strict
Truth table0%0/3
A and B
A= $token_type == 106B= $no_strict
ABresult
0X0
100
111
85 0 $statements_num_of_after_no_strict++;
86 0 ▶ if ($statements_num_of_after_no_strict > $allow_statements_num) {
Branch: 1 branch
BranchTrueFalseTotal
if ($statements_num_of_after_no_strict > $allow_statements_num) 0 0 0
87 push @violations, {
88 filename => $file,
89 line => $no_strict->{line},
90 0 description => DESC,
91 explanation => EXPL,
92 policy => __PACKAGE__,
93 };
94 0 last;
95 }
96 }
97 }
98  
99 0 return \@violations;
100 }
101  
102 2 1;
103  
« Perl/Lint/Policy/Subroutines/ProhibitReturnSort.pm ↑ Summary Perl/Lint/Policy/ClassHierarchies/ProhibitOneArgBless.pm »