Perl/Lint/Policy/BuiltinFunctions/ProhibitUniversalIsa.pm

filter: Statementstmt 51.6% 16 / 31 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 32.3% 21 / 65 CC 10 SCAR 43.0
CC
10
Cov
31%
evaluate
110.0
BEGIN
1.0
BEGIN
1.0
CRAP 73.7
« Perl/Lint/Policy/BuiltinFunctions/ProhibitUniversalCan.pm ↑ Summary Perl/Lint/Policy/ValuesAndExpressions/ProhibitVersionStrings.pm »
1 package Perl::Lint::Policy::BuiltinFunctions::ProhibitUniversalIsa;
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 => 'UNIVERSAL::isa should not be used as a function',
9 EXPL => 'Use eval{$obj->isa($pkg)} instead',
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=10 SCAR=47.0
Pod undocumented
13 0 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 0 my @violations;
16 0 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
17 0 my $token_type = $token->{type};
18 0 my $token_data = $token->{data};
19  
20 0 ▶ if ($token_type == KEY && $token_data eq 'isa') { # for isa()
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 122 and $token_data eq 'isa') { } 0 0 0
elsif ($token_type == 127 and $token_data eq 'UNIVERSAL') { } 0 0 0
Condition0%0/3
$token_type == 122 and $token_data eq "isa"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 122 and $token_data eq "isa"
$token_type == 122 $token_data eq "isa"
Truth table0%0/3
A and B
A= $token_type == 122B= $token_data eq "isa"
ABresult
0X0
100
111
21 0 $token = $tokens->[++$i];
22 0 ▶ if ($token->{type} == LEFT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 107) 0 0 0
23 push @violations, {
24 filename => $file,
25 line => $token->{line},
26 0 description => DESC,
27 explanation => EXPL,
28 policy => __PACKAGE__,
29 };
30 }
31 }
32 ▶ elsif ($token_type == NAMESPACE && $token_data eq 'UNIVERSAL') { # for UNIVERSAL::isa()
Condition0%0/3
$token_type == 127 and $token_data eq "UNIVERSAL"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 127 and $token_data eq "UNIVERSAL"
$token_type == 127 $token_data eq "UNIVERSAL"
Truth table0%0/3
A and B
A= $token_type == 127B= $token_data eq "UNIVERSAL"
ABresult
0X0
100
111
33 0 $i += 2; # skip the name space resolver
34 0 $token = $tokens->[$i];
35 0 ▶ if ($token->{type} == NAMESPACE && $token->{data} eq 'isa') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 127 and $token->{"data"} eq "isa") 0 0 0
Condition0%0/3
$token->{"type"} == 127 and $token->{"data"} eq "isa"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->{"type"} == 127 and $token->{"data"} eq "isa"
$token->{"type"} == 127 $token->{"data"} eq "isa"
Truth table0%0/3
A and B
A= $token->{"type"} == 127B= $token->{"data"} eq "isa"
ABresult
0X0
100
111
36 0 ▶ if ($tokens->[++$i]->{type} == LEFT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$tokens[++$i]{"type"} == 107) 0 0 0
37 push @violations, {
38 filename => $file,
39 line => $token->{line},
40 0 description => DESC,
41 explanation => EXPL,
42 policy => __PACKAGE__,
43 };
44 }
45 }
46 }
47 }
48  
49 0 return \@violations;
50 }
51  
52 2 1;
53  
« Perl/Lint/Policy/BuiltinFunctions/ProhibitUniversalCan.pm ↑ Summary Perl/Lint/Policy/ValuesAndExpressions/ProhibitVersionStrings.pm »