Perl/Lint/Policy/ClassHierarchies/ProhibitOneArgBless.pm

filter: Statementstmt 35.5% 16 / 45 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 24 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 18.5% 21 / 113 CC 22 SCAR 60.2
CC
22
Cov
17%
evaluate
506.0
BEGIN
1.0
BEGIN
1.0
CRAP 412.5
« Perl/Lint/Policy/TestingAndDebugging/ProhibitProlongedStrictureOverride.pm ↑ Summary Perl/Lint/Policy/ValuesAndExpressions/ProhibitMixedBooleanOperators.pm »
1 package Perl::Lint::Policy::ClassHierarchies::ProhibitOneArgBless;
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 => 'One-argument "bless" used',
9 EXPL => [365],
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=22 SCAR=62.3
Pod undocumented
13 0 my ($class, $file, $tokens, $args) = @_;
14  
15 0 my @violations;
16 0 my $token_num = scalar @$tokens;
17 0 ▶ for (my $i = 0; $i < $token_num; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $token_num) 0 0 0
18 0 my $token = $tokens->[$i];
19 0 my $token_type = $token->{type};
20 0 my $token_data = $token->{data};
21  
22 0 ▶ if ($token_type == BUILTIN_FUNC && $token_data eq 'bless') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 70 and $token_data eq "bless") 0 0 0
Condition0%0/3
$token_type == 70 and $token_data eq "bless"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 70 and $token_data eq "bless"
$token_type == 70 $token_data eq "bless"
Truth table0%0/3
A and B
A= $token_type == 70B= $token_data eq "bless"
ABresult
0X0
100
111
23 0 my $left_paren_num = 0;
24 0 my $left_brace_num = 0;
25 0 my $left_bracket_num = 0;
26 0 my $comma_num = 0;
27  
28 0 ▶ $i++ if $tokens->[$i+1]->{type} == LEFT_PAREN;
Branch: 1 branch
BranchTrueFalseTotal
if $$tokens[$i + 1]{"type"} == 107 0 0 0
29  
30 0 ▶ for ($i++; $i < $token_num; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $token_num) 0 0 0
31 0 my $token = $tokens->[$i];
32 0 my $token_type = $token->{type};
33 0 my $token_data = $token->{data};
34  
35 0 ▶ if ($token_type == LEFT_PAREN) {
Branch: 8 branches
BranchTrueFalseTotal
if ($token_type == 107) { } 0 0 0
elsif ($token_type == 109) { } 0 0 0
elsif ($token_type == 111) { } 0 0 0
elsif ($token_type == 108) { } 0 0 0
elsif ($token_type == 110) { } 0 0 0
elsif ($token_type == 112) { } 0 0 0
elsif ($token_type == 104 || $token_type == 124 and $left_paren_num <= 0 and $left_brace_num <= 0 and $left_bracket_num <= 0) { } 0 0 0
elsif ($token_type == 106 and $left_paren_num <= 0 and $left_brace_num <= 0 and $left_bracket_num <= 0) { } 0 0 0
36 0 $left_paren_num++;
37 }
38 elsif ($token_type == LEFT_BRACE) {
39 0 $left_brace_num++;
40 }
41 elsif ($token_type == LEFT_BRACKET) {
42 0 $left_bracket_num++;
43 }
44 elsif ($token_type == RIGHT_PAREN) {
45 0 $left_paren_num--;
46 }
47 elsif ($token_type == RIGHT_BRACE) {
48 0 $left_brace_num--;
49 }
50 elsif ($token_type == RIGHT_BRACKET) {
51 0 $left_bracket_num--;
52 }
53 ▶ elsif (
Condition0%0/12
$token_type == 104 || $token_type == 124 and $left_paren_num <= 0 and $left_brace_num <= 0 and $left_bracket_num <= 0
!ll&&!rl&&r
000
$token_type == 104 || $token_type == 124 and $left_paren_num <= 0 and $left_brace_num <= 0
!ll&&!rl&&r
000
$token_type == 104 || $token_type == 124 and $left_paren_num <= 0
!ll&&!rl&&r
000
$token_type == 104 or $token_type == 124
l!l&&r!l&&!r
000
MC/DC0%0/5
$token_type == 104 || $token_type == 124 and $left_paren_num <= 0 and $left_brace_num <= 0 and $left_bracket_num <= 0
$token_type == 104 $token_type == 124 $left_paren_num <= 0 $left_brace_num <= 0 $left_bracket_num <= 0
Truth table0%0/9
A or B and C and D and E
A= $token_type == 104B= $token_type == 124C= $left_paren_num <= 0D= $left_brace_num <= 0E= $left_bracket_num <= 0
ABCDEresult
00XXX0
1X0XX0
010XX0
1X10X0
0110X0
1X1100
011100
1X1111
011111
54 ($token_type == COMMA || $token_type == ARROW) &&
55 $left_paren_num <= 0 &&
56 $left_brace_num <= 0 &&
57 $left_bracket_num <= 0
58 ) {
59 0 $comma_num++;
60 }
61 ▶ elsif (
Condition0%0/9
$token_type == 106 and $left_paren_num <= 0 and $left_brace_num <= 0 and $left_bracket_num <= 0
!ll&&!rl&&r
000
$token_type == 106 and $left_paren_num <= 0 and $left_brace_num <= 0
!ll&&!rl&&r
000
$token_type == 106 and $left_paren_num <= 0
!ll&&!rl&&r
000
MC/DC0%0/4
$token_type == 106 and $left_paren_num <= 0 and $left_brace_num <= 0 and $left_bracket_num <= 0
$token_type == 106 $left_paren_num <= 0 $left_brace_num <= 0 $left_bracket_num <= 0
Truth table0%0/5
A and B and C and D
A= $token_type == 106B= $left_paren_num <= 0C= $left_brace_num <= 0D= $left_bracket_num <= 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
62 $token_type == SEMI_COLON &&
63 $left_paren_num <= 0 &&
64 $left_brace_num <= 0 &&
65 $left_bracket_num <= 0
66 ) {
67 0 ▶ if ($comma_num == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($comma_num == 0) 0 0 0
68 push @violations, {
69 filename => $file,
70 line => $token->{line},
71 0 description => DESC,
72 explanation => EXPL,
73 policy => __PACKAGE__,
74 };
75 }
76 0 last;
77 }
78 }
79 }
80 }
81  
82 0 return \@violations;
83 }
84  
85 2 1;
86  
« Perl/Lint/Policy/TestingAndDebugging/ProhibitProlongedStrictureOverride.pm ↑ Summary Perl/Lint/Policy/ValuesAndExpressions/ProhibitMixedBooleanOperators.pm »