blib/lib/Parse/PMFile.pm

filter: Statementstmt 67.2% 337 / 501 Branchbran 60.2% 159 / 264 Conditioncond 36.8% 59 / 160 MC/DCmcdc 15.9% 14 / 88 Subroutinesub 78.0% 32 / 41 Podpod 100% 2 / 2 totaltotal 57.1% 603 / 1056 CC 196 SCAR 39.5
CC
196
Cov
60%
_vcmp
272.0
parse
87.5
_perm_check
72.0
CRAP 51.9
↑ Summary
1 package Parse::PMFile;
2  
3 134 ▶sub __clean_eval { eval $_[0] } # needs to be here (RT#101273)
Subroutine __clean_eval: called CC=1 SCAR=0.0
4  
5 67 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 67 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 67 ▶use Safe;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 67 ▶use JSON::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 67 ▶use Dumpvalue;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 67 ▶use version ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 67 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 67 our $VERSION = '0.48';
14 67 our $VERBOSE = 0;
15 67 our $ALLOW_DEV_VERSION = 0;
16 67 our $FORK = 0;
17 67 ▶our $UNSAFE = $] < 5.010000 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$] < 5.01 ? : 0 67 67
18  
19 313 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
20 313 my ($class, $meta, $opts) = @_;
21 313 ▶ bless {%{ $opts || {} }, META_CONTENT => $meta}, $class;
Condition100%2/2
$opts || {}
l!l
4309
MC/DC100%1/1
$opts || {}
$opts
Truth table100%2/2
A
A= $opts
Aresult
11
00
22 }
23  
24 # from PAUSE::pmfile::examine_fio
25 314 ▶sub parse {
Subroutine parse: called CC=31 SCAR=44.7
Pod documented
26 314 my ($self, $pmfile) = @_;
27  
28 314 $pmfile =~ s|\\|/|g;
29  
30 314 my($filemtime) = (stat $pmfile)[9];
31 314 $self->{MTIME} = $filemtime;
32 314 $self->{PMFILE} = $pmfile;
33  
34 314 ▶ unless ($self->_version_from_meta_ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_version_from_meta_ok) 308 6 314
35 308 my $version;
36 308 ▶ unless (eval { $version = $self->_parse_version; 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { $version = $self->_parse_version; 1 } }) 0 267 267
37 0 $self->_verbose(1, "error with version in $pmfile: $@");
38 0 return;
39 }
40  
41 267 $self->{VERSION} = $version;
42 267 ▶ if ($self->{VERSION} =~ /^\{.*\}$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'VERSION'} =~ /^\{.*\}$/) { } 0 267 267
elsif ($self->{'VERSION'} =~ /[_\s]/ and not $self->{'ALLOW_DEV_VERSION'} and not $Parse::PMFile::ALLOW_DEV_VERSION) { } 5 521 526
43 # JSON error message
44 ▶ } elsif ($self->{VERSION} =~ /[_\s]/ && !$self->{ALLOW_DEV_VERSION} && !$ALLOW_DEV_VERSION){ # ignore developer releases and "You suck!"
Condition83%5/6
$self->{"VERSION"} =~ /[_\s]/ and not $self->{"ALLOW_DEV_VERSION"} and not $Parse::PMFile::ALLOW_DEV_VERSION
!ll&&!rl&&r
25935
$self->{"VERSION"} =~ /[_\s]/ and not $self->{"ALLOW_DEV_VERSION"}
!ll&&!rl&&r
25908
MC/DC66%2/3
$self->{"VERSION"} =~ /[_\s]/ and not $self->{"ALLOW_DEV_VERSION"} and not $Parse::PMFile::ALLOW_DEV_VERSION
$self->{"VERSION"} =~ /[_\s]/ not $self->{"ALLOW_DEV_VERSION"} not $Parse::PMFile::ALLOW_DEV_VERSION
Truth table75%3/4
A and not(B) and not(C)
A= $self->{"VERSION"} =~ /[_\s]/B= not $self->{"ALLOW_DEV_VERSION"}C= not $Parse::PMFile::ALLOW_DEV_VERSION
ABCresult
0XX0
10X0
1100
1111
45 5 return;
46 }
47 }
48  
49 268 my($ppp) = $self->_packages_per_pmfile;
50 268 my @keys_ppp = $self->_filter_ppps(sort keys %$ppp);
51 268 $self->_verbose(1,"Will check keys_ppp[@keys_ppp]\n");
52  
53 #
54 # Immediately after each package (pmfile) examined contact
55 # the database
56 #
57  
58 268 my ($package, %errors);
59 268 my %checked_in;
60 268 DBPACK: foreach $package (@keys_ppp) {
61 # this part is taken from PAUSE::package::examine_pkg
62 # and PAUSE::package::_pkg_name_insane
63 268 ▶ if ($package !~ /^\w[\w\:\']*\w?\z/
Branch: 1 branch
BranchTrueFalseTotal
if (not $package =~ /^\w[\w\:\']*\w?\z/ && $package =~ /\w\z/ or $package =~ /:/ and not $package =~ /::/ or $package =~ /\w:\w/ or $package =~ /:::/) 0 268 268
Condition33%5/15
not $package =~ /^\w[\w\:\']*\w?\z/ && $package =~ /\w\z/ or $package =~ /:/ and not $package =~ /::/ or $package =~ /\w:\w/ or $package =~ /:::/
l!l&&r!l&&!r
00268
not $package =~ /^\w[\w\:\']*\w?\z/ && $package =~ /\w\z/ or $package =~ /:/ and not $package =~ /::/ or $package =~ /\w:\w/
l!l&&r!l&&!r
00268
not $package =~ /^\w[\w\:\']*\w?\z/ && $package =~ /\w\z/ or $package =~ /:/ and not $package =~ /::/
l!l&&r!l&&!r
00268
$package =~ /^\w[\w\:\']*\w?\z/ && $package =~ /\w\z/
!ll&&!rl&&r
00268
$package =~ /:/ and not $package =~ /::/
!ll&&!rl&&r
02680
MC/DC0%0/6
not $package =~ /^\w[\w\:\']*\w?\z/ && $package =~ /\w\z/ or $package =~ /:/ and not $package =~ /::/ or $package =~ /\w:\w/ or $package =~ /:::/
$package =~ /^\w[\w\:\']*\w?\z/ $package =~ /\w\z/ $package =~ /:/ not $package =~ /::/ $package =~ /\w:\w/ $package =~ /:::/
Truth table11%1/9
not(A && B) or C and not(D) or E or F
A= $package =~ /^\w[\w\:\']*\w?\z/B= $package =~ /\w\z/C= $package =~ /:/D= not $package =~ /::/E= $package =~ /\w:\w/F= $package =~ /:::/
ABCDEFresult
0XXXXX1
10XXXX1
1111XX1
110X1X1
11101X1
110X011
1110011
110X000
1110000
64 || $package !~ /\w\z/
65 || $package =~ /:/ && $package !~ /::/
66 || $package =~ /\w:\w/
67 || $package =~ /:::/
68 ){
69 0 $self->_verbose(1,"Package[$package] did not pass the ultimate sanity check");
70 0 delete $ppp->{$package};
71 0 next;
72 }
73  
74 268 ▶ if ($self->{USERID} && $self->{PERMISSIONS} && !$self->_perm_check($package)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"USERID"} and $self->{"PERMISSIONS"} and not $self->_perm_check($package)) 0 268 268
Condition33%2/6
$self->{"USERID"} and $self->{"PERMISSIONS"} and not $self->_perm_check($package)
!ll&&!rl&&r
26800
$self->{"USERID"} and $self->{"PERMISSIONS"}
!ll&&!rl&&r
26800
MC/DC0%0/3
$self->{"USERID"} and $self->{"PERMISSIONS"} and not $self->_perm_check($package)
$self->{"USERID"} $self->{"PERMISSIONS"} not $self->_perm_check($package)
Truth table25%1/4
A and B and not(C)
A= $self->{"USERID"}B= $self->{"PERMISSIONS"}C= not $self->_perm_check($package)
ABCresult
0XX0
10X0
1100
1111
75 0 delete $ppp->{$package};
76 0 next;
77 }
78  
79 # Check that package name matches case of file name
80 {
81 268 my (undef, $module) = split m{/lib/}, $self->{PMFILE}, 2;
82 268 ▶ if ($module) {
Branch: 1 branch
BranchTrueFalseTotal
if ($module) 6 262 268
83 6 $module =~ s{\.pm\z}{};
84 6 $module =~ s{/}{::}g;
85  
86 6 ▶ if (lc $module eq lc $package && $module ne $package) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $module eq lc $package and $module ne $package) 0 6 6
Condition33%1/3
lc $module eq lc $package and $module ne $package
!ll&&!rl&&r
060
MC/DC0%0/2
lc $module eq lc $package and $module ne $package
lc $module eq lc $package $module ne $package
Truth table33%1/3
A and B
A= lc $module eq lc $packageB= $module ne $package
ABresult
0X0
100
111
87 # warn "/// $self->{PMFILE} vs. $module vs. $package\n";
88 $errors{$package} = {
89 indexing_warning => "Capitalization of package ($package) does not match filename!",
90 infile => $self->{PMFILE},
91 0 };
92 }
93 }
94 }
95  
96 268 my $pp = $ppp->{$package};
97 268 ▶ if ($pp->{version} && $pp->{version} =~ /^\{.*\}$/) { # JSON parser error
Branch: 1 branch
BranchTrueFalseTotal
if ($pp->{"version"} and $pp->{"version"} =~ /^\{.*\}$/) 0 268 268
Condition66%2/3
$pp->{"version"} and $pp->{"version"} =~ /^\{.*\}$/
!ll&&!rl&&r
42640
MC/DC0%0/2
$pp->{"version"} and $pp->{"version"} =~ /^\{.*\}$/
$pp->{"version"} $pp->{"version"} =~ /^\{.*\}$/
Truth table66%2/3
A and B
A= $pp->{"version"}B= $pp->{"version"} =~ /^\{.*\}$/
ABresult
0X0
100
111
98 0 my $err = JSON::PP::decode_json($pp->{version});
99 0 ▶ if ($err->{x_normalize}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($err->{'x_normalize'}) { } 0 0 0
elsif ($err->{'openerr'}) { } 0 0 0
100 $errors{$package} = {
101 normalize => $err->{version},
102 infile => $pp->{infile},
103 0 };
104 0 $pp->{version} = "undef";
105 } elsif ($err->{openerr}) {
106 0 $pp->{version} = "undef";
107 0 $self->_verbose(1,
108 qq{Parse::PMFile was not able to
109 read the file. It issued the following error: C< $err->{r} >},
110 );
111 $errors{$package} = {
112 open => $err->{r},
113 infile => $pp->{infile},
114 0 };
115 } else {
116 0 $pp->{version} = "undef";
117 0 $self->_verbose(1,
118 qq{Parse::PMFile was not able to
119 parse the following line in that file: C< $err->{line} >
120  
121 Note: the indexer is running in a Safe compartement and cannot
122 provide the full functionality of perl in the VERSION line. It
123 is trying hard, but sometime it fails. As a workaround, please
124 consider writing a META.yml that contains a 'provides'
125 attribute or contact the CPAN admins to investigate (yet
126 another) workaround against "Safe" limitations.)},
127  
128 );
129 $errors{$package} = {
130 parse_version => $err->{line},
131 infile => $err->{file},
132 0 };
133 }
134 }
135  
136 # Sanity checks
137  
138 268 for (
139 $package,
140 $pp->{version},
141 ) {
142 536 ▶ if (!defined || /^\s*$/ || /\s/){ # for whatever reason I come here
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $_ or /^\s*$/ or /\s/) 4 532 536
Condition66%4/6
not defined $_ or /^\s*$/ or /\s/
l!l&&r!l&&!r
40532
not defined $_ or /^\s*$/
l!l&&r!l&&!r
40532
MC/DC33%1/3
not defined $_ or /^\s*$/ or /\s/
not defined $_ /^\s*$/ /\s/
Truth table50%2/4
not(A) or B or C
A= not defined $_B= /^\s*$/C= /\s/
ABCresult
1XX1
01X1
0011
0000
143 4 delete $ppp->{$package};
144 4 next; # don't screw up 02packages
145 }
146 }
147 268 ▶ unless ($self->_version_ok($pp)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_version_ok($pp)) 3 265 268
148 $errors{$package} = {
149 long_version => qq{Version string exceeds maximum allowed length of 16b: "$pp->{version}"},
150 infile => $pp->{infile},
151 3 };
152 3 next;
153 }
154 265 $checked_in{$package} = $ppp->{$package};
155 } # end foreach package
156  
157 268 ▶ return (wantarray && %errors) ? (\%checked_in, \%errors) : \%checked_in;
Branch: 1 branch
BranchTrueFalseTotal
wantarray && %errors ? : 3 265 268
Condition66%2/3
wantarray and %errors
!ll&&!rl&&r
26503
MC/DC50%1/2
wantarray and %errors
wantarray %errors
Truth table66%2/3
A and B
A= wantarrayB= %errors
ABresult
0X0
100
111
158 }
159  
160 268 ▶sub _version_ok {
Subroutine _version_ok: called CC=3 SCAR=11.0
161 268 my ($self, $pp) = @_;
162 268 ▶ return if length($pp->{version} || 0) > 16;
Branch: 1 branch
BranchTrueFalseTotal
if length($pp->{"version"} || 0) > 16 3 265 268
Condition100%2/2
$pp->{'version'} || 0
l!l
2644
MC/DC100%1/1
$pp->{'version'} || 0
$pp->{'version'}
Truth table100%2/2
A
A= $pp->{'version'}
Aresult
11
00
163 265 return 1
164 }
165  
166 0 ▶sub _perm_check {
Subroutine _perm_check: not called CC=8 SCAR=42.8
167 0 my ($self, $package) = @_;
168 0 my $userid = $self->{USERID};
169 0 my $module = $self->{PERMISSIONS}->module_permissions($package);
170 0 ▶ return 1 if !$module; # not listed yet
Branch: 1 branch
BranchTrueFalseTotal
unless $module 0 0 0
171 0 ▶ return 1 if defined $module->m && $module->m eq $userid;
Branch: 1 branch
BranchTrueFalseTotal
if defined $module->m and $module->m eq $userid 0 0 0
Condition0%0/3
defined $module->m and $module->m eq $userid
!ll&&!rl&&r
000
MC/DC0%0/2
defined $module->m and $module->m eq $userid
defined $module->m $module->m eq $userid
Truth table0%0/3
A and B
A= defined $module->mB= $module->m eq $userid
ABresult
0X0
100
111
172 0 ▶ return 1 if defined $module->f && $module->f eq $userid;
Branch: 1 branch
BranchTrueFalseTotal
if defined $module->f and $module->f eq $userid 0 0 0
Condition0%0/3
defined $module->f and $module->f eq $userid
!ll&&!rl&&r
000
MC/DC0%0/2
defined $module->f and $module->f eq $userid
defined $module->f $module->f eq $userid
Truth table0%0/3
A and B
A= defined $module->fB= $module->f eq $userid
ABresult
0X0
100
111
173 0 ▶ return 1 if defined $module->c && grep {$_ eq $userid} @{$module->c};
Branch: 1 branch
BranchTrueFalseTotal
if defined $module->c and grep {$_ eq $userid;} @{$module->c;} 0 0 0
Condition0%0/3
defined $module->c and grep {$_ eq $userid;} @{$module->c;}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $module->c and grep {$_ eq $userid;} @{$module->c;}
defined $module->c grep {$_ eq $userid;} @{$module->c;}
Truth table0%0/3
A and B
A= defined $module->cB= grep {$_ eq $userid;} @{$module->c;}
ABresult
0X0
100
111
174 0 return;
175 }
176  
177 # from PAUSE::pmfile;
178 308 ▶sub _parse_version {
Subroutine _parse_version: called CC=31 SCAR=37.9
179 308 my $self = shift;
180  
181 67 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
182  
183 308 my $pmfile = $self->{PMFILE};
184 308 my $tmpfile = File::Spec->catfile(File::Spec->tmpdir, "ParsePMFile$$" . rand(1000));
185  
186 308 my $pmcp = $pmfile;
187 308 for ($pmcp) {
188 308 s/([^\\](\\\\)*)@/$1\\@/g; # thanks to Raphael Manfredi for the
189 # solution to escape @s and \
190 }
191 308 my($v);
192 {
193  
194 308 package main; # seems necessary
195  
196 # XXX: do we need to fork as PAUSE does?
197 # or, is alarm() just fine?
198 308 my $pid;
199 308 ▶ if ($self->{FORK} || $FORK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"FORK"} or $Parse::PMFile::FORK) 153 155 308
Condition66%2/3
$self->{"FORK"} or $Parse::PMFile::FORK
l!l&&r!l&&!r
0153155
MC/DC50%1/2
$self->{"FORK"} or $Parse::PMFile::FORK
$self->{"FORK"} $Parse::PMFile::FORK
Truth table66%2/3
A or B
A= $self->{"FORK"}B= $Parse::PMFile::FORK
ABresult
1X1
011
000
200 153 $pid = fork();
201 153 ▶ die "Can't fork: $!" unless defined $pid;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pid 0 153 153
202 }
203 308 ▶ if ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid) { } 112 196 308
204 112 waitpid($pid, 0);
205 112 ▶ if (open my $fh, '<', $tmpfile) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, "<", $tmpfile) 112 0 112
206 112 $v = <$fh>;
207 }
208 } else {
209 # XXX Limit Resources too
210  
211 196 my $comp;
212 196 my $eval = qq{
213 local(\$^W) = 0;
214 Parse::PMFile::_parse_version_safely("$pmcp");
215 };
216 196 ▶ unless ($self->{UNSAFE} || $UNSAFE) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"UNSAFE"} or $Parse::PMFile::UNSAFE) 196 0 196
Condition33%1/3
$self->{"UNSAFE"} or $Parse::PMFile::UNSAFE
l!l&&r!l&&!r
00196
MC/DC0%0/2
$self->{"UNSAFE"} or $Parse::PMFile::UNSAFE
$self->{"UNSAFE"} $Parse::PMFile::UNSAFE
Truth table33%1/3
A or B
A= $self->{"UNSAFE"}B= $Parse::PMFile::UNSAFE
ABresult
1X1
011
000
217 196 $comp = Safe->new;
218 196 $comp->permit("entereval"); # for MBARBON/Module-Info-0.30.tar.gz
219 196 $comp->share("*Parse::PMFile::_parse_version_safely");
220 196 $comp->share("*version::new");
221 196 $comp->share("*version::numify");
222 196 $comp->share_from('main', ['*version::',
223 '*charstar::',
224 '*Exporter::',
225 '*DynaLoader::']);
226 196 $comp->share_from('version', ['&qv']);
227 196 $comp->permit(":base_math"); # atan2 (Acme-Pi)
228 # $comp->permit("require"); # no strict!
229 196 $comp->deny(qw/enteriter iter unstack goto/); # minimum protection against Acme::BadExample
230 }
231  
232 196 ▶ version->import('qv') if $self->{UNSAFE} || $UNSAFE;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"UNSAFE"} or $Parse::PMFile::UNSAFE 0 196 196
Condition33%1/3
$self->{"UNSAFE"} or $Parse::PMFile::UNSAFE
l!l&&r!l&&!r
00196
MC/DC0%0/2
$self->{"UNSAFE"} or $Parse::PMFile::UNSAFE
$self->{"UNSAFE"} $Parse::PMFile::UNSAFE
Truth table33%1/3
A or B
A= $self->{"UNSAFE"}B= $Parse::PMFile::UNSAFE
ABresult
1X1
011
000
233 {
234 67 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
235 196 ▶ $v = $comp ? $comp->reval($eval) : eval $eval;
Branch: 1 branch
BranchTrueFalseTotal
$comp ? : 196 0 196
236 }
237 196 ▶ if ($@){ # still in the child process, out of Safe::reval
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 21 175 196
238 21 my $err = $@;
239 # warn ">>>>>>>err[$err]<<<<<<<<";
240 21 ▶ if (ref $err) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $err) { } 21 0 21
241 21 ▶ if ($err->{line} =~ /([\$*])([\w\:\']*)\bVERSION\b.*?\=(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err->{"line"} =~ /([\$*])([\w\:\']*)\bVERSION\b.*?\=(.*)/) 21 0 21
242 21 local($^W) = 0;
243 21 my ($sigil, $vstr) = ($1, $3);
244 21 ▶ $self->_restore_overloaded_stuff(1) if $err->{line} =~ /use\s+version\b|version\->|qv\(/;
Branch: 1 branch
BranchTrueFalseTotal
if $err->{"line"} =~ /use\s+version\b|version\->|qv\(/ 21 0 21
245 21 ▶ $v = $comp ? $comp->reval($vstr) : eval $vstr;
Branch: 1 branch
BranchTrueFalseTotal
$comp ? : 21 0 21
246 21 ▶ $v = $$v if $sigil eq '*' && ref $v;
Branch: 1 branch
BranchTrueFalseTotal
if $sigil eq "*" and ref $v 0 21 21
Condition33%1/3
$sigil eq "*" and ref $v
!ll&&!rl&&r
2100
MC/DC0%0/2
$sigil eq "*" and ref $v
$sigil eq "*" ref $v
Truth table33%1/3
A and B
A= $sigil eq "*"B= ref $v
ABresult
0X0
100
111
247 }
248 21 ▶ if ($@ or !$v) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or not $v) 0 21 21
Condition33%1/3
$@ or not $v
l!l&&r!l&&!r
0021
MC/DC0%0/2
$@ or not $v
$@ not $v
Truth table33%1/3
A or not(B)
A= $@B= not $v
ABresult
1X1
011
000
249 0 $self->_verbose(1, sprintf("reval failed: err[%s] for eval[%s]",
250 JSON::PP::encode_json($err),
251 $eval,
252 ));
253 0 $v = JSON::PP::encode_json($err);
254 }
255 } else {
256 0 $v = JSON::PP::encode_json({ openerr => $err });
257 }
258 }
259 196 ▶ if (defined $v) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $v) { } 196 0 196
260 67 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
261 196 ▶ $v = $v->numify if ref($v) =~ /^version(::vpp)?$/;
Branch: 1 branch
BranchTrueFalseTotal
if ref($v) =~ /^version(::vpp)?$/ 21 175 196
262 } else {
263 0 $v = "";
264 }
265 196 ▶ if ($self->{FORK} || $FORK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'FORK'} or $Parse::PMFile::FORK) { } 41 155 196
Condition66%2/3
$self->{"FORK"} or $Parse::PMFile::FORK
l!l&&r!l&&!r
041155
MC/DC50%1/2
$self->{"FORK"} or $Parse::PMFile::FORK
$self->{"FORK"} $Parse::PMFile::FORK
Truth table66%2/3
A or B
A= $self->{"FORK"}B= $Parse::PMFile::FORK
ABresult
1X1
011
000
266 41 open my $fh, '>:utf8', $tmpfile;
267 41 print $fh $v;
268 41 exit 0;
269 } else {
270 155 utf8::encode($v);
271 # undefine empty $v as if read from the tmpfile
272 155 ▶ $v = undef if defined $v && !length $v;
Branch: 1 branch
BranchTrueFalseTotal
if defined $v and not length $v 0 155 155
Condition33%1/3
defined $v and not length $v
!ll&&!rl&&r
01550
MC/DC0%0/2
defined $v and not length $v
defined $v not length $v
Truth table33%1/3
A and not(B)
A= defined $vB= not length $v
ABresult
0X0
100
111
273 155 ▶ $comp->erase if ($comp);
Branch: 1 branch
BranchTrueFalseTotal
if $comp 155 0 155
274 155 $self->_restore_overloaded_stuff;
275 }
276 }
277 }
278 267 ▶ unlink $tmpfile if ($self->{FORK} || $FORK) && -e $tmpfile;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"FORK"} || $Parse::PMFile::FORK and -e $tmpfile 112 155 267
Condition66%4/6
$self->{"FORK"} || $Parse::PMFile::FORK and -e $tmpfile
!ll&&!rl&&r
1550112
$self->{"FORK"} or $Parse::PMFile::FORK
l!l&&r!l&&!r
0112155
MC/DC33%1/3
$self->{"FORK"} || $Parse::PMFile::FORK and -e $tmpfile
$self->{"FORK"} $Parse::PMFile::FORK -e $tmpfile
Truth table40%2/5
A or B and C
A= $self->{"FORK"}B= $Parse::PMFile::FORKC= -e $tmpfile
ABCresult
00X0
1X00
0100
1X11
0111
279  
280 267 return $self->_normalize_version($v);
281 }
282  
283 176 ▶sub _restore_overloaded_stuff {
Subroutine _restore_overloaded_stuff: called CC=8 SCAR=34.6
284 176 my ($self, $used_version_in_safe) = @_;
285 176 ▶ return if $self->{UNSAFE} || $UNSAFE;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"UNSAFE"} or $Parse::PMFile::UNSAFE 0 176 176
Condition33%1/3
$self->{"UNSAFE"} or $Parse::PMFile::UNSAFE
l!l&&r!l&&!r
00176
MC/DC0%0/2
$self->{"UNSAFE"} or $Parse::PMFile::UNSAFE
$self->{"UNSAFE"} $Parse::PMFile::UNSAFE
Truth table33%1/3
A or B
A= $self->{"UNSAFE"}B= $Parse::PMFile::UNSAFE
ABresult
1X1
011
000
286  
287 67 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
288 67 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
289  
290 # version XS in CPAN
291 176 my $restored;
292 176 ▶ if ($INC{'version/vxs.pm'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"version/vxs.pm"}) 0 176 176
293 0 *{'version::(""'} = \&version::vxs::stringify;
294 0 *{'version::(0+'} = \&version::vxs::numify;
295 0 *{'version::(cmp'} = \&version::vxs::VCMP;
296 0 *{'version::(<=>'} = \&version::vxs::VCMP;
297 0 *{'version::(bool'} = \&version::vxs::boolean;
298 0 $restored = 1;
299 }
300 # version PP in CPAN
301 176 ▶ if ($INC{'version/vpp.pm'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"version/vpp.pm"}) 0 176 176
302 {
303 0 package # hide from PAUSE
304 charstar;
305 0 overload->import;
306 }
307 0 ▶ if (!$used_version_in_safe) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($used_version_in_safe) 0 0 0
308 package # hide from PAUSE
309 version::vpp;
310 0 overload->import;
311 }
312 0 ▶ unless ($restored) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($restored) 0 0 0
313 0 *{'version::(""'} = \&version::vpp::stringify;
314 0 *{'version::(0+'} = \&version::vpp::numify;
315 0 *{'version::(cmp'} = \&version::vpp::vcmp;
316 0 *{'version::(<=>'} = \&version::vpp::vcmp;
317 0 *{'version::(bool'} = \&version::vpp::vbool;
318 }
319 0 *{'version::vpp::(""'} = \&version::vpp::stringify;
320 0 *{'version::vpp::(0+'} = \&version::vpp::numify;
321 0 *{'version::vpp::(cmp'} = \&version::vpp::vcmp;
322 0 *{'version::vpp::(<=>'} = \&version::vpp::vcmp;
323 0 *{'version::vpp::(bool'} = \&version::vpp::vbool;
324 0 *{'charstar::(""'} = \&charstar::thischar;
325 0 *{'charstar::(0+'} = \&charstar::thischar;
326 0 *{'charstar::(++'} = \&charstar::increment;
327 0 *{'charstar::(--'} = \&charstar::decrement;
328 0 *{'charstar::(+'} = \&charstar::plus;
329 0 *{'charstar::(-'} = \&charstar::minus;
330 0 *{'charstar::(*'} = \&charstar::multiply;
331 0 *{'charstar::(cmp'} = \&charstar::cmp;
332 0 *{'charstar::(<=>'} = \&charstar::spaceship;
333 0 *{'charstar::(bool'} = \&charstar::thischar;
334 0 *{'charstar::(='} = \&charstar::clone;
335 0 $restored = 1;
336 }
337 # version in core
338 176 ▶ if (!$restored) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $restored) 176 0 176
339 176 *{'version::(""'} = \&version::stringify;
340 176 *{'version::(0+'} = \&version::numify;
341 176 *{'version::(cmp'} = \&version::vcmp;
342 176 *{'version::(<=>'} = \&version::vcmp;
343 176 *{'version::(bool'} = \&version::boolean;
344 }
345 }
346  
347 # from PAUSE::pmfile;
348 268 ▶sub _packages_per_pmfile {
Subroutine _packages_per_pmfile: called CC=37 SCAR=37.9
349 268 my $self = shift;
350  
351 268 my $ppp = {};
352 268 my $pmfile = $self->{PMFILE};
353 268 my $filemtime = $self->{MTIME};
354 268 my $version = $self->{VERSION};
355  
356 268 ▶ open my $fh, "<", "$pmfile" or return $ppp;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", "$pmfile" or return $ppp 268 0 268
357  
358 268 local $/ = "\n";
359 268 my $inpod = 0;
360  
361 268 my $package_or_class = 'package';
362 268 my $checked_bom;
363 268 ▶ PLINE: while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 6228 259 6487
364 6228 chomp;
365 6228 my($pline) = $_;
366 6228 ▶ $pline =~ s/\A(?:\x00\x00\xfe\xff|\xff\xfe\x00\x00|\xfe\xff|\xff\xfe|\xef\xbb\xbf)// unless $checked_bom;
Branch: 1 branch
BranchTrueFalseTotal
unless $checked_bom 268 5960 6228
367 6228 $checked_bom = 1;
368 6228 ▶ $inpod = $pline =~ /^=(?!cut)/ ? 1 :
Branch: 2 branches
BranchTrueFalseTotal
$pline =~ /^=(?!cut)/ ? : 6 6222 6228
$pline =~ /^=cut/ ? : 6 6216 6222
369 $pline =~ /^=cut/ ? 0 : $inpod;
370 6228 ▶ next if $inpod;
Branch: 1 branch
BranchTrueFalseTotal
if $inpod 60 6168 6228
371 6168 ▶ next if substr($pline,0,4) eq "=cut";
Branch: 1 branch
BranchTrueFalseTotal
if substr($pline, 0, 4) eq "=cut" 6 6162 6168
372  
373 6162 $pline =~ s/\#.*//;
374 6162 ▶ next if $pline =~ /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $pline =~ /^\s*$/ 1274 4888 6162
375 4888 ▶ if ($pline =~ /^__(?:END|DATA)__\b/
Branch: 1 branch
BranchTrueFalseTotal
if ($pline =~ /^__(?:END|DATA)__\b/ and not $pmfile =~ /\.PL$/) 9 4879 4888
Condition66%2/3
$pline =~ /^__(?:END|DATA)__\b/ and not $pmfile =~ /\.PL$/
!ll&&!rl&&r
487909
MC/DC50%1/2
$pline =~ /^__(?:END|DATA)__\b/ and not $pmfile =~ /\.PL$/
$pline =~ /^__(?:END|DATA)__\b/ not $pmfile =~ /\.PL$/
Truth table66%2/3
A and not(B)
A= $pline =~ /^__(?:END|DATA)__\b/B= not $pmfile =~ /\.PL$/
ABresult
0X0
100
111
376 and $pmfile !~ /\.PL$/ # PL files may well have code after __DATA__
377 ){
378 9 last PLINE;
379 }
380  
381 =pod
382 # hide in the pod block until 'class' is added to a version bundle
383 if ($pline =~ /^[\s\{;]*use\s(+v?5\.[0-9]+)/) {
384 my $version = $1;
385 my $version_bundle_for_class = version->parse("v5.xx.xx");
386 if (eval { version->parse($version) >= $version_bundle_for_class) {
387 $package_or_class = 'package|class|role';
388 }
389 next PLINE;
390 }
391 =cut
392  
393 # use feature 'class'; enabels class (and role, though not implemented yet)
394 4879 ▶ if ($pline =~ /^[\s\{;]*use\s+(?:feature|experimental)\s+[^;]+\b(?:class|all)[^;]*;/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pline =~ /^[\s\{;]*use\s+(?:feature|experimental)\s+[^;]+\b(?:class|all)[^;]*;/) 120 4759 4879
395 120 $package_or_class = 'package|class';
396 }
397  
398 # some modules also enables class and role
399 4879 ▶ if ($pline =~ /^[\s\{;]*use\s+(?:Feature::Compat::Class)[^;]*;/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pline =~ /^[\s\{;]*use\s+(?:Feature::Compat::Class)[^;]*;/) 0 4879 4879
400 0 $package_or_class = 'package|class';
401 }
402 4879 ▶ if ($pline =~ /^[\s\{;]*use\s+(?:Object::Pad)[^;]*;/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pline =~ /^[\s\{;]*use\s+(?:Object::Pad)[^;]*;/) 48 4831 4879
403 48 $package_or_class = 'package|class|role';
404 }
405  
406 4879 my $pkg;
407 my $strict_version;
408  
409 4879 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($pline =~ / # (.*) # takes too much time if $pline is long #(?<![*\$\\@%&]) # no sigils ^[\s\{;]* \b(?:$package_or_class)\s+ ([\w\:\']+) \s* (?: $ | [\}\;\:] | \{ | \s+($version::STRICT) ) /x) 277 4602 4879
410 # If you change *anything* here, it needs changing in '_parse_version_safely' too
411 $pline =~ m{
412 # (.*) # takes too much time if $pline is long
413 #(?<![*\$\\@%&]) # no sigils
414 ^[\s\{;]*
415 \b(?:$package_or_class)\s+
416 ([\w\:\']+)
417 \s*
418 (?: $ | [\}\;\:] | \{ | \s+($version::STRICT) )
419 }x) {
420 277 $pkg = $1;
421 277 $strict_version = $2;
422 277 ▶ if ($pkg eq "DB"){
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg eq "DB") 0 277 277
423 # XXX if pumpkin and perl make him comaintainer! I
424 # think I always made the pumpkins comaint on DB
425 # without further ado (?)
426 0 next PLINE;
427 }
428 }
429  
430 4879 ▶ if ($pkg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg) { } 277 4602 4879
431 # Found something
432  
433 # from package
434 277 $pkg =~ s/\'/::/g;
435 277 ▶ next PLINE unless $pkg =~ /^[A-Za-z]/;
Branch: 1 branch
BranchTrueFalseTotal
unless $pkg =~ /^[A-Za-z]/ 0 277 277
436 277 ▶ next PLINE unless $pkg =~ /\w$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $pkg =~ /\w$/ 0 277 277
437 277 ▶ next PLINE if $pkg eq "main";
Branch: 1 branch
BranchTrueFalseTotal
if $pkg eq "main" 6 271 277
438 # Perl::Critic::Policy::TestingAndDebugging::ProhibitShebangWarningsArg
439 # database for modid in mods, package in packages, package in perms
440 # alter table mods modify modid varchar(128) binary NOT NULL default '';
441 # alter table packages modify package varchar(128) binary NOT NULL default '';
442 271 ▶ next PLINE if length($pkg) > 128;
Branch: 1 branch
BranchTrueFalseTotal
if length $pkg > 128 0 271 271
443 #restriction
444 271 $ppp->{$pkg}{parsed}++;
445 271 $ppp->{$pkg}{infile} = $pmfile;
446 271 ▶ if ($self->_simile($pmfile,$pkg)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_simile($pmfile, $pkg)) { } 265 6 271
447 265 $ppp->{$pkg}{simile} = $pmfile;
448 265 ▶ if ($self->_version_from_meta_ok) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_version_from_meta_ok) { } 6 259 265
449 6 my $provides = $self->{META_CONTENT}{provides};
450 6 ▶ if (exists $provides->{$pkg}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $provides->{$pkg}) 6 0 6
451 6 ▶ if (defined $provides->{$pkg}{version}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $provides->{$pkg}{'version'}) { } 6 0 6
452 6 my $v = $provides->{$pkg}{version};
453 6 ▶ if ($v =~ /[_\s]/ && !$self->{ALLOW_DEV_VERSION} && !$ALLOW_DEV_VERSION){ # ignore developer releases and "You suck!"
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /[_\s]/ and not $self->{"ALLOW_DEV_VERSION"} and not $Parse::PMFile::ALLOW_DEV_VERSION) 4 2 6
Condition50%3/6
$v =~ /[_\s]/ and not $self->{"ALLOW_DEV_VERSION"} and not $Parse::PMFile::ALLOW_DEV_VERSION
!ll&&!rl&&r
024
$v =~ /[_\s]/ and not $self->{"ALLOW_DEV_VERSION"}
!ll&&!rl&&r
006
MC/DC33%1/3
$v =~ /[_\s]/ and not $self->{"ALLOW_DEV_VERSION"} and not $Parse::PMFile::ALLOW_DEV_VERSION
$v =~ /[_\s]/ not $self->{"ALLOW_DEV_VERSION"} not $Parse::PMFile::ALLOW_DEV_VERSION
Truth table50%2/4
A and not(B) and not(C)
A= $v =~ /[_\s]/B= not $self->{"ALLOW_DEV_VERSION"}C= not $Parse::PMFile::ALLOW_DEV_VERSION
ABCresult
0XX0
10X0
1100
1111
454 4 next PLINE;
455 }
456  
457 2 ▶ unless (eval { $version = $self->_normalize_version($v); 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { $version = $self->_normalize_version($v); 1 } }) 0 2 2
458 0 $self->_verbose(1, "error with version in $pmfile: $@");
459 0 next;
460  
461 }
462 2 $ppp->{$pkg}{version} = $version;
463 } else {
464 0 $ppp->{$pkg}{version} = "undef";
465 }
466 }
467 } else {
468 259 ▶ if (defined $strict_version){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $strict_version) { } 19 240 259
469 19 $ppp->{$pkg}{version} = $strict_version ;
470 } else {
471 240 ▶ $ppp->{$pkg}{version} = defined $version ? $version : "";
Branch: 1 branch
BranchTrueFalseTotal
defined $version ? : 240 0 240
472 }
473 67 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
474 259 ▶ if ($version eq 'undef') {
Branch: 1 branch
BranchTrueFalseTotal
if ($version eq 'undef') { } 75 184 259
475 75 ▶ $ppp->{$pkg}{version} = $version unless defined $ppp->{$pkg}{version};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ppp->{$pkg}{"version"} 0 75 75
476 } else {
477 $ppp->{$pkg}{version} =
478 $version
479 if $version
480 > $ppp->{$pkg}{version} ||
481 $version
482 184 ▶ gt $ppp->{$pkg}{version};
Branch: 1 branch
BranchTrueFalseTotal
if $version > $ppp->{$pkg}{"version"} or $version gt $ppp->{$pkg}{"version"} 0 184 184
Condition33%1/3
$version > $ppp->{$pkg}{"version"} or $version gt $ppp->{$pkg}{"version"}
l!l&&r!l&&!r
00184
MC/DC0%0/2
$version > $ppp->{$pkg}{"version"} or $version gt $ppp->{$pkg}{"version"}
$version > $ppp->{$pkg}{"version"} $version gt $ppp->{$pkg}{"version"}
Truth table33%1/3
A or B
A= $version > $ppp->{$pkg}{"version"}B= $version gt $ppp->{$pkg}{"version"}
ABresult
1X1
011
000
483 }
484 }
485 } else { # not simile
486 #### it comes later, it would be nonsense
487 #### to set to "undef". MM_Unix gives us
488 #### the best we can reasonably consider
489 $ppp->{$pkg}{version} =
490 $version
491 unless defined $ppp->{$pkg}{version} &&
492 6 ▶ length($ppp->{$pkg}{version});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ppp->{$pkg}{"version"} and length $ppp->{$pkg}{"version"} 6 0 6
Condition33%1/3
defined $ppp->{$pkg}{"version"} and length $ppp->{$pkg}{"version"}
!ll&&!rl&&r
600
MC/DC0%0/2
defined $ppp->{$pkg}{"version"} and length $ppp->{$pkg}{"version"}
defined $ppp->{$pkg}{"version"} length $ppp->{$pkg}{"version"}
Truth table33%1/3
A and B
A= defined $ppp->{$pkg}{"version"}B= length $ppp->{$pkg}{"version"}
ABresult
0X0
100
111
493 }
494 267 $ppp->{$pkg}{filemtime} = $filemtime;
495 267 $ppp->{$pkg}{version} .= ""; # make sure to stringify version
496 } else {
497 # $self->_verbose(2,"no pkg found");
498 }
499 }
500  
501 268 close $fh;
502 268 $ppp;
503 }
504  
505 # from PAUSE::pmfile;
506 {
507 67 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
508 196 ▶ sub _parse_version_safely {
Subroutine _parse_version_safely: called CC=18 SCAR=29.2
509 196 my($parsefile) = @_;
510 196 my $result;
511 196 local *FH;
512 196 local $/ = "\n";
513 196 ▶ open(FH,$parsefile) or die "Could not open '$parsefile': $!";
Branch: 1 branch
BranchTrueFalseTotal
open FH, $parsefile or die "Could not open '${parsefile}': $!" 196 0 196
514 196 my $inpod = 0;
515 196 my $package_or_class = 'package';
516 196 ▶ while (<FH>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline FH)) 559 42 601
517 559 ▶ $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
Branch: 2 branches
BranchTrueFalseTotal
/^=(?!cut)/ ? : 0 559 559
/^=cut/ ? : 0 559 559
518 559 ▶ next if $inpod || /^\s*#/;
Branch: 1 branch
BranchTrueFalseTotal
if $inpod or /^\s*#/ 0 559 559
Condition33%1/3
$inpod or /^\s*#/
l!l&&r!l&&!r
00559
MC/DC0%0/2
$inpod or /^\s*#/
$inpod /^\s*#/
Truth table33%1/3
A or B
A= $inpodB= /^\s*#/
ABresult
1X1
011
000
519 559 ▶ last if /^__(?:END|DATA)__\b/; # fails on quoted __END__ but this is rare -> __END__ in the middle of a line is rarer
Branch: 1 branch
BranchTrueFalseTotal
if /^__(?:END|DATA)__\b/ 3 556 559
520 556 chop;
521  
522 # use feature 'class'; enabels class (and role, though not implemented yet)
523 556 ▶ if (/^[\s\{;]*use\s+(?:feature|experimental)\s+[^;]+\b(?:class|all)[^;]*;/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^[\s\{;]*use\s+(?:feature|experimental)\s+[^;]+\b(?:class|all)[^;]*;/) 75 481 556
524 75 $package_or_class = 'package|class';
525 }
526  
527 # some modules also enables class and role
528 # XXX: what to do with MooseX::Declare and a few minor experiments)
529 556 ▶ if (/^[\s\{;]*use\s+(?:Feature::Compat::Class)[^;]*;/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^[\s\{;]*use\s+(?:Feature::Compat::Class)[^;]*;/) 0 556 556
530 0 $package_or_class = 'package|class';
531 }
532 556 ▶ if (/^[\s\{;]*use\s+(?:Object::Pad)[^;]*;/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^[\s\{;]*use\s+(?:Object::Pad)[^;]*;/) 33 523 556
533 33 $package_or_class = 'package|class|role';
534 }
535  
536 # If you change *anything* here, it needs changing in '_packages_per_pmfile' too
537 556 ▶ if (my ($ver) = /$package_or_class \s+ \S+ \s+ (\S+) \s* [:;{]/x) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($ver) = /$package_or_class \s+ \S+ \s+ (\S+) \s* [:;{]/x) 39 517 556
538 # XXX: should handle this better if version is bogus -- rjbs,
539 # 2014-03-16
540 39 ▶ return $ver if version::is_lax($ver);
Branch: 1 branch
BranchTrueFalseTotal
if version::is_lax($ver) 17 22 39
541 }
542  
543 # next unless /\$(([\w\:\']*)\bVERSION)\b.*\=/;
544 539 ▶ next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*(?<![!><=])\=(?![=>])/;
Branch: 1 branch
BranchTrueFalseTotal
unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*(?<![!><=])\=(?![=>])/ 405 134 539
545 134 my $current_parsed_line = $_;
546 134 my $eval = qq{
547 package #
548 ExtUtils::MakeMaker::_version;
549  
550 local $1$2;
551 \$$2=undef; do {
552 $_
553 }; \$$2
554 };
555 134 local $^W = 0;
556 134 ▶ local $SIG{__WARN__} = sub {};
Subroutine __ANON__: not called CC=1 SCAR=0.0
557 134 $result = __clean_eval($eval);
558 # warn "current_parsed_line[$current_parsed_line]\$\@[$@]";
559 134 ▶ if ($@ or !defined $result){
Branch: 1 branch
BranchTrueFalseTotal
if ($@ or not defined $result) 21 113 134
Condition66%2/3
$@ or not defined $result
l!l&&r!l&&!r
210113
MC/DC50%1/2
$@ or not defined $result
$@ not defined $result
Truth table66%2/3
A or not(B)
A= $@B= not defined $result
ABresult
1X1
011
000
560 21 die +{
561 eval => $eval,
562 line => $current_parsed_line,
563 file => $parsefile,
564 err => $@,
565 };
566 }
567 113 last;
568 } #;
569 158 close FH;
570  
571 158 ▶ $result = "undef" unless defined $result;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $result 45 113 158
572 158 ▶ if ((ref $result) =~ /^version(?:::vpp)?\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($result) =~ /^version(?:::vpp)?\b/) 6 152 158
573 67 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
574 6 $result = $result->numify;
575 }
576 158 return $result;
577 }
578 }
579  
580 # from PAUSE::pmfile;
581 67 ▶sub _filter_ppps {
Subroutine _filter_ppps: called CC=11 SCAR=26.3
582 268 my($self,@ppps) = @_;
583 268 my @res;
584  
585 # very similar code is in PAUSE::dist::filter_pms
586 268 MANI: for my $ppp ( @ppps ) {
587 271 ▶ if ($self->{META_CONTENT}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'META_CONTENT'}) { } 9 262 271
588 my $no_index = $self->{META_CONTENT}{no_index}
589 9 ▶ || $self->{META_CONTENT}{private}; # backward compat
Condition66%2/3
$self->{'META_CONTENT'}{'no_index'} || $self->{'META_CONTENT'}{'private'}
l!l&&r!l&&!r
306
MC/DC50%1/2
$self->{'META_CONTENT'}{'no_index'} || $self->{'META_CONTENT'}{'private'}
$self->{'META_CONTENT'}{'no_index'} $self->{'META_CONTENT'}{'private'}
Truth table66%2/3
A || B
A= $self->{'META_CONTENT'}{'no_index'}B= $self->{'META_CONTENT'}{'private'}
ABresult
1X1
011
000
590 9 ▶ if (ref($no_index) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $no_index eq 'HASH') { } 3 6 9
591 3 my %map = (
592 package => qr{\z},
593 namespace => qr{::},
594 );
595 3 for my $k (qw(package namespace)) {
596 3 ▶ next unless my $v = $no_index->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless my $v = $no_index->{$k} 0 3 3
597 3 my $rest = $map{$k};
598 3 ▶ if (ref $v eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v eq 'ARRAY') { } 3 0 3
599 3 for my $ve (@$v) {
600 3 $ve =~ s|::$||;
601 3 ▶ if ($ppp =~ /^$ve$rest/){
Branch: 1 branch
BranchTrueFalseTotal
if ($ppp =~ /^$ve$rest/) { } 3 0 3
602 3 $self->_verbose(1,"Skipping ppp[$ppp] due to ve[$ve]");
603 3 next MANI;
604 } else {
605 0 $self->_verbose(1,"NOT skipping ppp[$ppp] due to ve[$ve]");
606 }
607 }
608 } else {
609 0 $v =~ s|::$||;
610 0 ▶ if ($ppp =~ /^$v$rest/){
Branch: 1 branch
BranchTrueFalseTotal
if ($ppp =~ /^$v$rest/) { } 0 0 0
611 0 $self->_verbose(1,"Skipping ppp[$ppp] due to v[$v]");
612 0 next MANI;
613 } else {
614 0 $self->_verbose(1,"NOT skipping ppp[$ppp] due to v[$v]");
615 }
616 }
617 }
618 } else {
619 6 $self->_verbose(1,"No keyword 'no_index' or 'private' in META_CONTENT");
620 }
621 } else {
622 # $self->_verbose(1,"no META_CONTENT"); # too noisy
623 }
624 268 push @res, $ppp;
625 }
626 268 $self->_verbose(1,"Result of filter_ppps: res[@res]");
627 268 @res;
628 }
629  
630 # from PAUSE::pmfile;
631 271 ▶sub _simile {
Subroutine _simile: called CC=4 SCAR=13.9
632 271 my($self,$file,$package) = @_;
633 # MakeMaker gives them the chance to have the file Simple.pm in
634 # this directory but have the package HTML::Simple in it.
635 # Afaik, they wouldn't be able to do so with deeper nested packages
636 271 $file =~ s|.*/||;
637 271 $file =~ s|\.pm(?:\.PL)?||;
638 271 my $ret = $package =~ m/\b\Q$file\E$/;
639 271 ▶ $ret ||= 0;
Condition100%2/2
$ret ||= 0
l!l
2656
MC/DC100%1/1
$ret ||= 0
$ret
Truth table100%2/2
A
A= $ret
Aresult
11
00
640 271 ▶ unless ($ret) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ret) 6 265 271
641 # Apache::mod_perl_guide stuffs it into Version.pm
642 6 ▶ $ret = 1 if lc $file eq 'version';
Branch: 1 branch
BranchTrueFalseTotal
if lc $file eq "version" 0 6 6
643 }
644 271 $self->_verbose(1,"Result of simile(): file[$file] package[$package] ret[$ret]\n");
645 271 $ret;
646 }
647  
648 # from PAUSE::pmfile
649 269 ▶sub _normalize_version {
Subroutine _normalize_version: called CC=11 SCAR=24.8
650 269 my($self,$v) = @_;
651 269 ▶ $v = "undef" unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 269 269
652 269 my $dv = Dumpvalue->new;
653 269 my $sdv = $dv->stringify($v,1); # second argument prevents ticks
654 269 $self->_verbose(1,"Result of normalize_version: sdv[$sdv]\n");
655  
656 269 ▶ return $v if $v eq "undef";
Branch: 1 branch
BranchTrueFalseTotal
if $v eq "undef" 75 194 269
657 194 ▶ return $v if $v =~ /^\{.*\}$/; # JSON object
Branch: 1 branch
BranchTrueFalseTotal
if $v =~ /^\{.*\}$/ 0 194 194
658 194 $v =~ s/^\s+//;
659 194 $v =~ s/\s+\z//;
660 194 ▶ if ($v =~ /_/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /_/) 10 184 194
661 # XXX should pass something like EDEVELOPERRELEASE up e.g.
662 # SIXTEASE/XML-Entities-0.0306.tar.gz had nothing but one
663 # such modules and the mesage was not helpful that "nothing
664 # was found".
665 10 return $v ;
666 }
667 184 ▶ if (!version::is_lax($v)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (version::is_lax($v)) 0 184 184
668 0 return JSON::PP::encode_json({ x_normalize => 'version::is_lax failed', version => $v });
669 }
670 # may warn "Integer overflow"
671 67 ▶ my $vv = eval { no warnings; version->new($v)->numify };
Subroutine BEGIN: called CC=1 SCAR=0.0
672 184 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 184 184
673 # warn "$v: $@";
674 0 return JSON::PP::encode_json({ x_normalize => $@, version => $v });
675 # return "undef";
676 }
677 184 ▶ if ($vv eq $v) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vv eq $v) { } 27 157 184
678 # the boring 3.14
679 } else {
680 157 my $forced = $self->_force_numeric($v);
681 157 ▶ if ($forced eq $vv) {
Branch: 2 branches
BranchTrueFalseTotal
if ($forced eq $vv) { } 0 157 157
elsif ($forced =~ /^v(.+)/) { } 0 157 157
682 } elsif ($forced =~ /^v(.+)/) {
683 # rare case where a v1.0.23 slipped in (JANL/w3mir-1.0.10.tar.gz)
684 67 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
685 0 $vv = version->new($1)->numify;
686 } else {
687 # warn "Unequal forced[$forced] and vv[$vv]";
688 157 ▶ if ($forced == $vv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($forced == $vv) 157 0 157
689 # the trailing zeroes would cause unnecessary havoc
690 157 $vv = $forced;
691 }
692 }
693 }
694 184 return $vv;
695 }
696  
697 # from PAUSE::pmfile;
698 157 ▶sub _force_numeric {
Subroutine _force_numeric: called CC=8 SCAR=27.1
699 157 my($self,$v) = @_;
700 157 $v = $self->_readable($v);
701  
702 157 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /^(\+?)(\d*)(\.(\d*))?/ and defined $2 && length $2 || defined $4 && length $4) 157 0 157
Condition25%3/12
$v =~ /^(\+?)(\d*)(\.(\d*))?/ and defined $2 && length $2 || defined $4 && length $4
!ll&&!rl&&r
00157
defined $2 and length $2 or defined $4 and length $4
l!l&&r!l&&!r
15700
defined $2 and length $2
!ll&&!rl&&r
00157
defined $4 and length $4
!ll&&!rl&&r
000
MC/DC0%0/5
$v =~ /^(\+?)(\d*)(\.(\d*))?/ and defined $2 && length $2 || defined $4 && length $4
$v =~ /^(\+?)(\d*)(\.(\d*))?/ defined $2 length $2 defined $4 length $4
Truth table12%1/8
A and B and C or D and E
A= $v =~ /^(\+?)(\d*)(\.(\d*))?/B= defined $2C= length $2D= defined $4E= length $4
ABCDEresult
0XXXX0
10X0X0
10X100
1100X0
110100
111XX1
10X111
110111
703 $v =~
704 /^(\+?)(\d*)(\.(\d*))?/ &&
705 # "$2$4" ne ''
706 (
707 defined $2 && length $2
708 ||
709 defined $4 && length $4
710 )
711 ) {
712 157 ▶ my $two = defined $2 ? $2 : "";
Branch: 1 branch
BranchTrueFalseTotal
defined $2 ? : 157 0 157
713 157 ▶ my $three = defined $3 ? $3 : "";
Branch: 1 branch
BranchTrueFalseTotal
defined $3 ? : 157 0 157
714 157 $v = "$two$three";
715 }
716 # no else branch! We simply say, everything else is a string.
717 157 $v;
718 }
719  
720 # from PAUSE::dist
721 579 ▶sub _version_from_meta_ok {
Subroutine _version_from_meta_ok: called CC=9 SCAR=32.3
722 579 my($self) = @_;
723 579 ▶ return $self->{VERSION_FROM_META_OK} if exists $self->{VERSION_FROM_META_OK};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"VERSION_FROM_META_OK"} 266 313 579
724 313 my $c = $self->{META_CONTENT};
725  
726 # If there's no provides hash, we can't get our module versions from the
727 # provides hash! -- rjbs, 2012-03-31
728 313 ▶ return($self->{VERSION_FROM_META_OK} = 0) unless $c->{provides};
Branch: 1 branch
BranchTrueFalseTotal
unless $c->{"provides"} 307 6 313
729  
730 # Some versions of Module::Build geneated an empty provides hash. If we're
731 # *not* looking at a Module::Build-generated metafile, then it's okay.
732 6 ▶ my ($mb_v) = (defined $c->{generated_by} ? $c->{generated_by} : '') =~ /Module::Build version ([\d\.]+)/;
Branch: 1 branch
BranchTrueFalseTotal
defined $c->{'generated_by'} ? : 0 6 6
733 6 ▶ return($self->{VERSION_FROM_META_OK} = 1) unless $mb_v;
Branch: 1 branch
BranchTrueFalseTotal
unless $mb_v 6 0 6
734  
735 # ??? I don't know why this is here.
736 0 ▶ return($self->{VERSION_FROM_META_OK} = 1) if $mb_v eq '0.250.0';
Branch: 1 branch
BranchTrueFalseTotal
if $mb_v eq "0.250.0" 0 0 0
737  
738 0 ▶ if ($mb_v >= 0.19 && $mb_v < 0.26 && ! keys %{$c->{provides}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mb_v >= "0.19" and $mb_v < "0.26" and not keys %{$$c{"provides"};}) 0 0 0
Condition0%0/6
$mb_v >= "0.19" and $mb_v < "0.26" and not keys %{$$c{"provides"};}
!ll&&!rl&&r
000
$mb_v >= "0.19" and $mb_v < "0.26"
!ll&&!rl&&r
000
MC/DC0%0/3
$mb_v >= "0.19" and $mb_v < "0.26" and not keys %{$$c{"provides"};}
$mb_v >= "0.19" $mb_v < "0.26" not keys %{$$c{"provides"};}
Truth table0%0/4
A and B and not(C)
A= $mb_v >= "0.19"B= $mb_v < "0.26"C= not keys %{$$c{"provides"};}
ABCresult
0XX0
10X0
1100
1111
739 # RSAVAGE/Javascript-SHA1-1.01.tgz had an empty provides hash. Ron
740 # did not find the reason why this happened, but let's not go
741 # overboard, 0.26 seems a good threshold from the statistics: there
742 # are not many empty provides hashes from 0.26 up.
743 0 return($self->{VERSION_FROM_META_OK} = 0);
744 }
745  
746 # We're not in the suspect range of M::B versions. It's good to go.
747 0 return($self->{VERSION_FROM_META_OK} = 1);
748 }
749  
750 1085 ▶sub _verbose {
Subroutine _verbose: called CC=4 SCAR=17.9
751 1085 my($self,$level,@what) = @_;
752 1085 ▶ warn @what if $level <= ((ref $self && $self->{VERBOSE}) || $VERBOSE);
Branch: 1 branch
BranchTrueFalseTotal
if $level <= (ref $self && $self->{"VERBOSE"} || $Parse::PMFile::VERBOSE) 0 1085 1085
Condition33%2/6
ref $self && $self->{'VERBOSE'} || $Parse::PMFile::VERBOSE
l!l&&r!l&&!r
001085
ref $self and $self->{"VERBOSE"}
!ll&&!rl&&r
010850
MC/DC0%0/3
ref $self && $self->{'VERBOSE'} || $Parse::PMFile::VERBOSE
ref $self $self->{"VERBOSE"} $Parse::PMFile::VERBOSE
Truth table20%1/5
A and B || C
A= ref $selfB= $self->{"VERBOSE"}C= $Parse::PMFile::VERBOSE
ABCresult
11X1
0X11
1011
0X00
1000
753 }
754  
755 # all of the following methods are stripped from CPAN::Version
756 # (as of version 5.5001, bundled in CPAN 2.03), and slightly
757 # modified (ie. made private, as well as CPAN->debug(...) are
758 # replaced with $self->_verbose(9, ...).)
759  
760 # CPAN::Version::vcmp courtesy Jost Krieger
761 0 ▶sub _vcmp {
Subroutine _vcmp: not called CC=16 SCAR=56.1
762 0 my($self,$l,$r) = @_;
763 0 local($^W) = 0;
764 0 $self->_verbose(9, "l[$l] r[$r]");
765  
766 0 ▶ return 0 if $l eq $r; # short circuit for quicker success
Branch: 1 branch
BranchTrueFalseTotal
if $l eq $r 0 0 0
767  
768 0 for ($l,$r) {
769 0 s/_//g;
770 }
771 0 $self->_verbose(9, "l[$l] r[$r]");
772 0 for ($l,$r) {
773 0 ▶ next unless tr/.// > 1 || /^v/;
Branch: 1 branch
BranchTrueFalseTotal
unless tr/.// > 1 or /^v/ 0 0 0
Condition0%0/3
tr/.// > 1 or /^v/
l!l&&r!l&&!r
000
MC/DC0%0/2
tr/.// > 1 or /^v/
tr/.// > 1 /^v/
Truth table0%0/3
A or B
A= tr/.// > 1B= /^v/
ABresult
1X1
011
000
774 0 s/^v?/v/;
775 0 ▶ 1 while s/\.0+(\d)/.$1/; # remove leading zeroes per group
Branch: 1 branch
BranchTrueFalseTotal
s/\.0+(\d)/.$1/ and do { '???' } 0 0 0
776 }
777 0 $self->_verbose(9, "l[$l] r[$r]");
778 0 ▶ if ($l=~/^v/ <=> $r=~/^v/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /^v/ <=> $r =~ /^v/) 0 0 0
779 0 for ($l,$r) {
780 0 ▶ next if /^v/;
Branch: 1 branch
BranchTrueFalseTotal
if /^v/ 0 0 0
781 0 $_ = $self->_float2vv($_);
782 }
783 }
784 0 $self->_verbose(9, "l[$l] r[$r]");
785 0 my $lvstring = "v0";
786 0 my $rvstring = "v0";
787 0 ▶ if ($] >= 5.006
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= "5.006" and $l =~ /^v/ and $r =~ /^v/) 0 0 0
Condition0%0/6
$] >= "5.006" and $l =~ /^v/ and $r =~ /^v/
!ll&&!rl&&r
000
$] >= "5.006" and $l =~ /^v/
!ll&&!rl&&r
000
MC/DC0%0/3
$] >= "5.006" and $l =~ /^v/ and $r =~ /^v/
$] >= "5.006" $l =~ /^v/ $r =~ /^v/
Truth table0%0/4
A and B and C
A= $] >= "5.006"B= $l =~ /^v/C= $r =~ /^v/
ABCresult
0XX0
10X0
1100
1111
788 && $l =~ /^v/
789 && $r =~ /^v/) {
790 0 $lvstring = $self->_vstring($l);
791 0 $rvstring = $self->_vstring($r);
792 0 $self->_verbose(9, sprintf "lv[%vd] rv[%vd]", $lvstring, $rvstring);
793 }
794  
795 return (
796 0 ▶ ($l ne "undef") <=> ($r ne "undef")
Condition0%0/9
($l ne 'undef') <=> ($r ne 'undef') || $lvstring cmp $rvstring || $l <=> $r || $l cmp $r
l!l&&r!l&&!r
000
($l ne "undef") <=> ($r ne "undef") or $lvstring cmp $rvstring or $l <=> $r
l!l&&r!l&&!r
000
($l ne "undef") <=> ($r ne "undef") or $lvstring cmp $rvstring
l!l&&r!l&&!r
000
MC/DC0%0/4
($l ne 'undef') <=> ($r ne 'undef') || $lvstring cmp $rvstring || $l <=> $r || $l cmp $r
($l ne "undef") <=> ($r ne "undef") $lvstring cmp $rvstring $l <=> $r $l cmp $r
Truth table0%0/5
A or B or C || D
A= ($l ne "undef") <=> ($r ne "undef")B= $lvstring cmp $rvstringC= $l <=> $rD= $l cmp $r
ABCDresult
1XXX1
01XX1
001X1
00011
00000
797 ||
798 $lvstring cmp $rvstring
799 ||
800 $l <=> $r
801 ||
802 $l cmp $r
803 );
804 }
805  
806 0 ▶sub _vgt {
Subroutine _vgt: not called CC=1 SCAR=6.9
807 0 my($self,$l,$r) = @_;
808 0 $self->_vcmp($l,$r) > 0;
809 }
810  
811 0 ▶sub _vlt {
Subroutine _vlt: not called CC=1 SCAR=6.9
812 0 my($self,$l,$r) = @_;
813 0 $self->_vcmp($l,$r) < 0;
814 }
815  
816 0 ▶sub _vge {
Subroutine _vge: not called CC=1 SCAR=6.9
817 0 my($self,$l,$r) = @_;
818 0 $self->_vcmp($l,$r) >= 0;
819 }
820  
821 0 ▶sub _vle {
Subroutine _vle: not called CC=1 SCAR=6.9
822 0 my($self,$l,$r) = @_;
823 0 $self->_vcmp($l,$r) <= 0;
824 }
825  
826 0 ▶sub _vstring {
Subroutine _vstring: not called CC=2 SCAR=17.9
827 0 my($self,$n) = @_;
828 0 ▶ $n =~ s/^v// or die "Parse::PMFile::_vstring() called with invalid arg [$n]";
Branch: 1 branch
BranchTrueFalseTotal
$n =~ s/^v// or die "Parse::PMFile::_vstring() called with invalid arg [$n]" 0 0 0
829 0 pack "U*", split /\./, $n;
830 }
831  
832 # vv => visible vstring
833 0 ▶sub _float2vv {
Subroutine _float2vv: not called CC=6 SCAR=37.4
834 0 my($self,$n) = @_;
835 0 my($rev) = int($n);
836 0 ▶ $rev ||= 0;
Condition0%0/2
$rev ||= 0
l!l
00
MC/DC0%0/1
$rev ||= 0
$rev
Truth table0%0/2
A
A= $rev
Aresult
11
00
837 0 my($mantissa) = $n =~ /\.(\d{1,12})/; # limit to 12 digits to limit
838 # architecture influence
839 0 ▶ $mantissa ||= 0;
Condition0%0/2
$mantissa ||= 0
l!l
00
MC/DC0%0/1
$mantissa ||= 0
$mantissa
Truth table0%0/2
A
A= $mantissa
Aresult
11
00
840 0 ▶ $mantissa .= "0" while length($mantissa)%3;
Branch: 1 branch
BranchTrueFalseTotal
length($mantissa) % 3 and do { $mantissa .= '0' } 0 0 0
841 0 my $ret = "v" . $rev;
842 0 ▶ while ($mantissa) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mantissa) 0 0 0
843 0 ▶ $mantissa =~ s/(\d{1,3})// or
Branch: 1 branch
BranchTrueFalseTotal
$mantissa =~ s/(\d{1,3})// or die "Panic: length>0 but not a digit? mantissa[$mantissa]" 0 0 0
844 die "Panic: length>0 but not a digit? mantissa[$mantissa]";
845 0 $ret .= ".".int($1);
846 }
847 # warn "n[$n]ret[$ret]";
848 0 $ret =~ s/(\.0)+/.0/; # v1.0.0 => v1.0
849 0 $ret;
850 }
851  
852 157 ▶sub _readable {
Subroutine _readable: called CC=4 SCAR=22.2
853 157 my($self,$n) = @_;
854 157 $n =~ /^([\w\-\+\.]+)/;
855  
856 157 ▶ return $1 if defined $1 && length($1)>0;
Branch: 1 branch
BranchTrueFalseTotal
if defined $1 and length $1 > 0 157 0 157
Condition33%1/3
defined $1 and length $1 > 0
!ll&&!rl&&r
00157
MC/DC0%0/2
defined $1 and length $1 > 0
defined $1 length $1 > 0
Truth table33%1/3
A and B
A= defined $1B= length $1 > 0
ABresult
0X0
100
111
857 # if the first user reaches version v43, he will be treated as "+".
858 # We'll have to decide about a new rule here then, depending on what
859 # will be the prevailing versioning behavior then.
860  
861 0 ▶ if ($] < 5.006) { # or whenever v-strings were introduced
Branch: 1 branch
BranchTrueFalseTotal
if ($] < "5.006") 0 0 0
862 # we get them wrong anyway, whatever we do, because 5.005 will
863 # have already interpreted 0.2.4 to be "0.24". So even if he
864 # indexer sends us something like "v0.2.4" we compare wrongly.
865  
866 # And if they say v1.2, then the old perl takes it as "v12"
867  
868 0 $self->_verbose(9, "Suspicious version string seen [$n]\n");
869 0 return $n;
870 }
871 0 my $better = sprintf "v%vd", $n;
872 0 $self->_verbose(9, "n[$n] better[$better]");
873 0 return $better;
874 }
875  
876 67 1;
877  
878 __END__
↑ Summary