Perl/Lint/Policy/Subroutines/ProhibitAmpersandSigils.pm

filter: Statementstmt 84.6% 33 / 39 Branchbran 65.0% 13 / 20 Conditioncond 26.6% 4 / 15 MC/DCmcdc 12.5% 1 / 8 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 64.0% 57 / 89 CC 16 SCAR 32.7
CC
16
Cov
68%
evaluate
34.1
BEGIN
1.0
BEGIN
1.0
CRAP 26.2
« Perl/Lint/Policy/ValuesAndExpressions/ProhibitSpecialHeredocTerminator.pm ↑ Summary Perl/Lint/Policy/RegularExpressions/ProhibitUselessTopic.pm »
1 package Perl::Lint::Policy::Subroutines::ProhibitAmpersandSigils;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Perl::Lint::Constants::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use parent "Perl::Lint::Policy";
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 DESC => 'Subroutine called with "&" sigil',
9 EXPL => [175],
10 3 };
11  
12 2 ▶sub evaluate {
Subroutine evaluate: called CC=16 SCAR=35.3
Pod undocumented
13 2 my ($class, $file, $tokens, $args) = @_;
14  
15 2 my @violations;
16 2 my $is_before_token_function = 0;
17 2 my $is_in_ref = 0;
18 2 my $left_paren_num = 0;
19 2 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 51 2 53
20 51 my $token_type = $token->{type};
21  
22 51 ▶ if ($token_type == BIT_AND) {
Branch: 5 branches
BranchTrueFalseTotal
if ($token_type == 15) { } 0 51 51
elsif ($token_type == 122 or $token_type == 70 or $token_type == 85) { } 1 50 51
elsif ($token_type == 10) { } 0 50 50
elsif ($token_type == 107) { } 1 49 50
elsif ($token_type == 108) { } 1 48 49
23 0 my $next_token_type = $tokens->[++$i]->{type};
24 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($next_token_type == 122 or $next_token_type == 127 or $next_token_type == 126) 0 0 0
Condition0%0/6
$next_token_type == 122 or $next_token_type == 127 or $next_token_type == 126
l!l&&r!l&&!r
000
$next_token_type == 122 or $next_token_type == 127
l!l&&r!l&&!r
000
MC/DC0%0/3
$next_token_type == 122 or $next_token_type == 127 or $next_token_type == 126
$next_token_type == 122 $next_token_type == 127 $next_token_type == 126
Truth table0%0/4
A or B or C
A= $next_token_type == 122B= $next_token_type == 127C= $next_token_type == 126
ABCresult
1XX1
01X1
0011
0000
25 $next_token_type == KEY ||
26 $next_token_type == NAMESPACE ||
27 $next_token_type == NAMESPACE_RESOLVER
28 ) {
29 0 ▶ if (!$is_before_token_function && !$is_in_ref) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_before_token_function or $is_in_ref) 0 0 0
Condition0%0/3
$is_before_token_function or $is_in_ref
l!l&&r!l&&!r
000
MC/DC0%0/2
$is_before_token_function or $is_in_ref
$is_before_token_function $is_in_ref
Truth table0%0/3
A or B
A= $is_before_token_functionB= $is_in_ref
ABresult
1X1
011
000
30 push @violations, {
31 filename => $file,
32 line => $token->{line},
33 0 description => DESC,
34 explanation => EXPL,
35 policy => __PACKAGE__,
36 };
37 0 next;
38 }
39 }
40 }
41 ▶ elsif ($token_type == KEY || $token_type == BUILTIN_FUNC || $token_type == GOTO) {
Condition66%4/6
$token_type == 122 or $token_type == 70 or $token_type == 85
l!l&&r!l&&!r
1050
$token_type == 122 or $token_type == 70
l!l&&r!l&&!r
0150
MC/DC33%1/3
$token_type == 122 or $token_type == 70 or $token_type == 85
$token_type == 122 $token_type == 70 $token_type == 85
Truth table50%2/4
A or B or C
A= $token_type == 122B= $token_type == 70C= $token_type == 85
ABCresult
1XX1
01X1
0011
0000
42 1 $is_before_token_function = 1;
43 }
44 elsif ($token_type == REF) {
45 0 $is_in_ref = 1;
46 }
47 elsif ($token_type == LEFT_PAREN) {
48 1 $left_paren_num++;
49 }
50 elsif ($token_type == RIGHT_PAREN) {
51 1 $left_paren_num--;
52 1 ▶ if ($left_paren_num <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_paren_num <= 0) 1 0 1
53 1 $is_in_ref = 0;
54 }
55 }
56 else {
57 48 ▶ if ($left_paren_num <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_paren_num <= 0) 37 11 48
58 37 $is_in_ref = 0;
59 }
60 48 $is_before_token_function = 0;
61 }
62 }
63  
64 2 return \@violations;
65 }
66  
67 3 1;
68  
« Perl/Lint/Policy/ValuesAndExpressions/ProhibitSpecialHeredocTerminator.pm ↑ Summary Perl/Lint/Policy/RegularExpressions/ProhibitUselessTopic.pm »