Perl/Lint/Policy/Modules/RequireVersionVar.pm

filter: Statementstmt 40.0% 16 / 40 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 20.3% 21 / 103 CC 18 SCAR 55.9
CC
18
Cov
19%
evaluate
342.0
BEGIN
1.0
BEGIN
1.0
CRAP 267.9
« Perl/Lint/Policy/RegularExpressions/ProhibitFixedStringMatches.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/ProhibitVoidGrep.pm »
1 package Perl::Lint::Policy::Modules::RequireVersionVar;
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 => 'No package-scoped "$VERSION" variable found',
9 EXPL => [404],
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=18 SCAR=58.3
Pod undocumented
13 0 my ($class, $file, $tokens, $args) = @_;
14  
15 0 my @violations;
16 0 my $does_exist_version_ver = 0;
17 0 ▶ TOP: for (my $i = 0, my $next_token, my $token_type, my $token_data; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
18 0 $next_token = $tokens->[$i+1];
19 0 $token_type = $token->{type};
20 0 $token_data = $token->{data};
21  
22 0 ▶ if ($token_type == USED_NAME && $token_data eq 'vars') {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 94 and $token_data eq 'vars') { } 0 0 0
elsif ($token_type == 194 and $token_data eq '$VERSION' or $token_type == 129 and $next_token->{'type'} == 171 or $token_type == 126 and $next_token->{'type'} == 127 and $next_token->{'data'} eq 'VERSION') { } 0 0 0
Condition0%0/3
$token_type == 94 and $token_data eq "vars"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 94 and $token_data eq "vars"
$token_type == 94 $token_data eq "vars"
Truth table0%0/3
A and B
A= $token_type == 94B= $token_data eq "vars"
ABresult
0X0
100
111
23 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($next_token->{"type"} == 173 and $next_token->{"data"} eq "\$VERSION") 0 0 0
Condition0%0/3
$next_token->{"type"} == 173 and $next_token->{"data"} eq "\$VERSION"
!ll&&!rl&&r
000
MC/DC0%0/2
$next_token->{"type"} == 173 and $next_token->{"data"} eq "\$VERSION"
$next_token->{"type"} == 173 $next_token->{"data"} eq "\$VERSION"
Truth table0%0/3
A and B
A= $next_token->{"type"} == 173B= $next_token->{"data"} eq "\$VERSION"
ABresult
0X0
100
111
24 $next_token->{type} == RAW_STRING &&
25 $next_token->{data} eq '$VERSION'
26 ) {
27 0 $does_exist_version_ver = 1;
28 0 last;
29 }
30 0 ▶ for ($i++; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
31 0 my $token_type = $token->{type};
32 0 my $token_data = $token->{data};
33 0 ▶ if ($token_type == SEMI_COLON) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 106) 0 0 0
34 0 last;
35 }
36  
37 0 ▶ if ($token_type == REG_EXP && $token_data eq '$VERSION') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 187 and $token_data eq "\$VERSION") 0 0 0
Condition0%0/3
$token_type == 187 and $token_data eq "\$VERSION"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 187 and $token_data eq "\$VERSION"
$token_type == 187 $token_data eq "\$VERSION"
Truth table0%0/3
A and B
A= $token_type == 187B= $token_data eq "\$VERSION"
ABresult
0X0
100
111
38 0 $does_exist_version_ver = 1;
39 0 last TOP;
40 }
41 }
42 }
43 ▶ elsif (
Condition0%0/18
$token_type == 194 and $token_data eq "\$VERSION" or $token_type == 129 and $next_token->{"type"} == 171 or $token_type == 126 and $next_token->{"type"} == 127 and $next_token->{"data"} eq "VERSION"
l!l&&r!l&&!r
000
$token_type == 194 and $token_data eq "\$VERSION" or $token_type == 129 and $next_token->{"type"} == 171
l!l&&r!l&&!r
000
$token_type == 194 and $token_data eq "\$VERSION"
!ll&&!rl&&r
000
$token_type == 129 and $next_token->{"type"} == 171
!ll&&!rl&&r
000
$token_type == 126 and $next_token->{"type"} == 127 and $next_token->{"data"} eq "VERSION"
!ll&&!rl&&r
000
$token_type == 126 and $next_token->{"type"} == 127
!ll&&!rl&&r
000
MC/DC0%0/7
$token_type == 194 and $token_data eq "\$VERSION" or $token_type == 129 and $next_token->{"type"} == 171 or $token_type == 126 and $next_token->{"type"} == 127 and $next_token->{"data"} eq "VERSION"
$token_type == 194 $token_data eq "\$VERSION" $token_type == 129 $next_token->{"type"} == 171 $token_type == 126 $next_token->{"type"} == 127 $next_token->{"data"} eq "VERSION"
Truth table0%0/19
A and B or C and D or E and F and G
A= $token_type == 194B= $token_data eq "\$VERSION"C= $token_type == 129D= $next_token->{"type"} == 171E= $token_type == 126F= $next_token->{"type"} == 127G= $next_token->{"data"} eq "VERSION"
ABCDEFGresult
11XXXXX1
0X11XXX1
1011XXX1
0X0X1111
0X101111
100X1111
10101111
0X0X0XX0
0X0X10X0
0X0X1100
0X100XX0
0X1010X0
0X101100
100X0XX0
100X10X0
100X1100
10100XX0
101010X0
10101100
44 ($token_type == GLOBAL_VAR && $token_data eq '$VERSION') ||
45 ($token_type == CLASS && $next_token->{type} == DOUBLE) ||
46 (
47 $token_type == NAMESPACE_RESOLVER &&
48 $next_token->{type} == NAMESPACE &&
49 $next_token->{data} eq 'VERSION'
50 )
51 ) {
52 0 $does_exist_version_ver = 1;
53 0 last;
54 }
55 }
56  
57 0 ▶ unless ($does_exist_version_ver) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($does_exist_version_ver) 0 0 0
58 0 push @violations, {
59 filename => $file,
60 line => 1, # TODO
61 description => DESC,
62 explanation => EXPL,
63 policy => __PACKAGE__,
64 };
65 }
66  
67 0 return \@violations;
68 }
69  
70 2 1;
71  
« Perl/Lint/Policy/RegularExpressions/ProhibitFixedStringMatches.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/ProhibitVoidGrep.pm »