Perl/Lint/Policy/Subroutines/ProhibitBuiltinHomonyms.pm

filter: Statementstmt 57.8% 22 / 38 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 1 totaltotal 42.6% 29 / 68 CC 9 SCAR 39.3
CC
9
Cov
39%
evaluate
90.0
BEGIN
1.0
BEGIN
1.0
CRAP 51.1
« Perl/Lint/Policy/ControlStructures/ProhibitPostfixControls.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/ProhibitStringySplit.pm »
1 package Perl::Lint::Policy::Subroutines::ProhibitBuiltinHomonyms;
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 Perl::Lint::Keywords;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use List::Util qw/any/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use parent "Perl::Lint::Policy";
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 DESC => 'Subroutine name is a homonym for builtin %s %s',
11 EXPL => [177],
12 2 };
13  
14 0 ▶sub evaluate {
Subroutine evaluate: not called CC=9 SCAR=45.0
Pod undocumented
15 0 my ($class, $file, $tokens, $args) = @_;
16  
17 0 my @violations;
18 0 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
19 0 my $token_type = $token->{type};
20 0 ▶ if ($token_type == FUNCTION_DECL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 63) 0 0 0
21 0 my $token = $tokens->[++$i];
22 0 my $token_data = $token->{data};
23 0 ▶ if ($token->{type} == FUNCTION) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 203) 0 0 0
24 0 ▶ next if $token_data eq 'import' || $token_data eq 'AUTOLOAD' || $token_data eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $token_data eq "import" or $token_data eq "AUTOLOAD" or $token_data eq "DESTROY" 0 0 0
Condition0%0/6
$token_data eq "import" or $token_data eq "AUTOLOAD" or $token_data eq "DESTROY"
l!l&&r!l&&!r
000
$token_data eq "import" or $token_data eq "AUTOLOAD"
l!l&&r!l&&!r
000
MC/DC0%0/3
$token_data eq "import" or $token_data eq "AUTOLOAD" or $token_data eq "DESTROY"
$token_data eq "import" $token_data eq "AUTOLOAD" $token_data eq "DESTROY"
Truth table0%0/4
A or B or C
A= $token_data eq "import"B= $token_data eq "AUTOLOAD"C= $token_data eq "DESTROY"
ABCresult
1XX1
01X1
0011
0000
25  
26 0 my $homonym_type;
27 0 ▶ if (is_perl_builtin($token_data)) {
Branch: 2 branches
BranchTrueFalseTotal
if (is_perl_builtin($token_data)) { } 0 0 0
elsif (is_perl_bareword($token_data)) { } 0 0 0
28 0 $homonym_type = 'function';
29 }
30 elsif (is_perl_bareword($token_data)) {
31 0 $homonym_type = 'keyword';
32 }
33 else {
34 0 next;
35 }
36  
37 push @violations, {
38 filename => $file,
39 line => $token->{line},
40 0 description => sprintf(DESC, $homonym_type, $token_data),
41 explanation => EXPL,
42 policy => __PACKAGE__,
43 };
44 }
45 }
46 }
47  
48 0 return \@violations;
49 }
50  
51 2 1;
52  
« Perl/Lint/Policy/ControlStructures/ProhibitPostfixControls.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/ProhibitStringySplit.pm »