Perl/Lint/Policy/Variables/ProhibitPerl4PackageNames.pm

filter: Statementstmt 63.1% 24 / 38 Branchbran 25.0% 6 / 24 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 48.6% 36 / 74 CC 14 SCAR 41.5
CC
14
Cov
46%
evaluate
85.4
BEGIN
1.0
BEGIN
1.0
CRAP 63.2
« Perl/Lint/Policy/Modules/ProhibitEvilModules.pm ↑ Summary Perl/Lint/Policy/RegularExpressions/ProhibitUnusualDelimiters.pm »
1 package Perl::Lint::Policy::Variables::ProhibitPerl4PackageNames;
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 => 'Using the obsolete single quote as package separator',
9 EXPL => q{Use double colon (::) to separate package name components instead of single quotes (')},
10 3 };
11  
12 2 ▶sub evaluate {
Subroutine evaluate: called CC=14 SCAR=44.5
Pod undocumented
13 2 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 2 my @violations;
16 2 ▶ for (
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 51 2 53
17 my $i = 0, my $token_type, my $token_data, my $is_just_before_left_brace = 0;
18 my $token = $tokens->[$i];
19 $i++
20 ) {
21 51 $token_type = $token->{type};
22  
23 51 ▶ if ($token_type == NAMESPACE_RESOLVER) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token_type == 126) { } 0 51 51
elsif ($token_type == 109) { } 1 50 51
elsif ($token_type != 127) { } 50 0 50
24 0 ▶ my $is_perl4_package_name = $token->{data} eq q{'} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$token->{'data'} eq q['] ? : 0 0 0
25  
26 0 ▶ for ($i++; $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $tokens->[$i]) 0 0 0
27 0 $token_type = $token->{type};
28  
29 0 ▶ if ($token_type == NAMESPACE_RESOLVER) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 126) { } 0 0 0
elsif ($token_type != 127) { } 0 0 0
30 0 ▶ if ($token->{data} eq q{'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} eq "'") 0 0 0
31 0 $is_perl4_package_name = 1;
32 }
33 }
34 elsif ($token_type != NAMESPACE) {
35 0 last;
36 }
37 }
38  
39 0 ▶ if ($is_perl4_package_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_perl4_package_name) 0 0 0
40 0 ▶ if ($is_just_before_left_brace) { # XXX workaround, for example `$foo{ bar'baz }`
Branch: 1 branch
BranchTrueFalseTotal
if ($is_just_before_left_brace) 0 0 0
41 0 next;
42 }
43  
44 0 ▶ if ($token && $token->{type} == ARROW) { # XXX workaround, for example `$foo = { bar'baz => 0 }`
Branch: 1 branch
BranchTrueFalseTotal
if ($token and $token->{"type"} == 124) 0 0 0
Condition0%0/3
$token and $token->{"type"} == 124
!ll&&!rl&&r
000
MC/DC0%0/2
$token and $token->{"type"} == 124
$token $token->{"type"} == 124
Truth table0%0/3
A and B
A= $tokenB= $token->{"type"} == 124
ABresult
0X0
100
111
45 0 next;
46 }
47  
48 push @violations, {
49 filename => $file,
50 line => $token->{line},
51 0 description => DESC,
52 explanation => EXPL,
53 policy => __PACKAGE__,
54 };
55 }
56  
57 0 $is_just_before_left_brace = 0;
58 }
59 elsif ($token_type == LEFT_BRACE) {
60 1 $is_just_before_left_brace = 1;
61 }
62 elsif ($token_type != NAMESPACE) {
63 50 $is_just_before_left_brace = 0;
64 }
65 }
66  
67 2 return \@violations;
68 }
69  
70 3 1;
71  
« Perl/Lint/Policy/Modules/ProhibitEvilModules.pm ↑ Summary Perl/Lint/Policy/RegularExpressions/ProhibitUnusualDelimiters.pm »