MinimumVersion.pm

filter: Statementstmt 90.4% 446 / 493 Branchbran 70.7% 276 / 390 Conditioncond 67.2% 119 / 177 MC/DCmcdc 46.6% 49 / 105 Subroutinesub 93.1% 95 / 102 Podpod 58.3% 7 / 12 totaltotal 77.5% 992 / 1279 CC 269 SCAR 29.5
CC
269
Cov
79%
__ANON__
226.3
__ANON__
42.0
minimum_reason
30.0
CRAP 19.2
↑ Summary MinimumVersion/Reason.pm »
1 package Perl::MinimumVersion;
2 21 $Perl::MinimumVersion::VERSION = '1.44';
3 =pod
4  
5 =head1 NAME
6  
7 Perl::MinimumVersion - Find a minimum required version of perl for Perl code
8  
9 =head1 SYNOPSIS
10  
11 # Create the version checking object
12 $object = Perl::MinimumVersion->new( $filename );
13 $object = Perl::MinimumVersion->new( \$source );
14 $object = Perl::MinimumVersion->new( $ppi_document );
15  
16 # Find the minimum version
17 $version = $object->minimum_version;
18  
19 =head1 DESCRIPTION
20  
21 C<Perl::MinimumVersion> takes Perl source code and calculates the minimum
22 version of perl required to be able to run it. Because it is based on
23 L<PPI>, it can do this without having to actually load the code.
24  
25 Currently it tests both the syntax of your code, and the use of explicit
26 version dependencies such as C<require 5.008>.
27  
28 Future plans are to also add support for tracing module dependencies.
29  
30 Using C<Perl::MinimumVersion> is dead simple, the synopsis pretty much
31 covers it.
32  
33 The distribution comes with a script called L<perlver>,
34 which is the easiest way to run C<Perl::MinimumVersion> on your code:
35  
36 % perlver lib/Foo/Bar.pm
37  
38 See the L<documentation for perlver|perlver> for more details.
39  
40 =head1 METHODS
41  
42 =cut
43  
44 21 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 21 ▶use version 0.76 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
48 21 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
49 21 ▶use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
50 21 ▶use List::Util 1.20 qw(max first);
Subroutine BEGIN: called CC=1 SCAR=0.0
51 21 ▶use Params::Util 0.25 ('_INSTANCE', '_CLASS');
Subroutine BEGIN: called CC=1 SCAR=0.0
52 21 ▶use PPI::Util ('_Document');
Subroutine BEGIN: called CC=1 SCAR=0.0
53 21 ▶use PPI 1.252 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
54 21 ▶use PPIx::Utils qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
55 :classification
56 :traversal
57 21 };
58 21 ▶use PPIx::Regexp 0.051;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 21 ▶use Perl::MinimumVersion::Reason ();
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 21 our (@ISA, @EXPORT_OK, %CHECKS, @CHECKS_RV ,%MATCHES);
62 21 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
63 # Export the PMV convenience constant
64 21 @ISA = 'Exporter';
65 21 @EXPORT_OK = 'PMV';
66  
67 # The primary list of version checks
68 21 %CHECKS = (
69 _heredoc_indent => version->new('5.025.007'),
70 _double_diamond_operator => version->new('5.021.005'),
71 _postfix_deref => version->new('5.020'),
72  
73 # _stacked_labels => version->new('5.014'),
74  
75 _yada_yada_yada => version->new('5.012'),
76 _pkg_name_version => version->new('5.012'),
77 _postfix_when => version->new('5.012'),
78 _perl_5012_pragmas => version->new('5.012'),
79 _while_readdir => version->new('5.012'),
80  
81 _perl_5010_pragmas => version->new('5.010'),
82 _perl_5010_operators => version->new('5.010'),
83 _perl_5010_magic => version->new('5.010'),
84 _state_declaration => version->new('5.010'),
85  
86 # Various small things
87 _bugfix_magic_errno => version->new('5.008.003'),
88 _is_utf8 => version->new('5.008.001'),
89 _unquoted_versions => version->new('5.008.001'),
90 _perl_5008_pragmas => version->new('5.008'),
91 _constant_hash => version->new('5.008'),
92 _local_soft_reference => version->new('5.008'),
93 _use_carp_version => version->new('5.008'),
94 _open_temp => version->new('5.008'),
95 _open_scalar => version->new('5.008'),
96 _internals_svreadonly => version->new('5.008'),
97  
98 # Included in 5.6. Broken until 5.8
99 _pragma_utf8 => version->new('5.008'),
100 );
101 21 @CHECKS_RV = ( #subs that return version
102 '_feature_bundle', '_regex', '_re_flags', '_each_argument', '_binmode_2_arg',
103 '_scheduled_blocks', '_experimental_bundle',
104 );
105  
106 # Predefine some indexes needed by various check methods
107 21 %MATCHES = (
108 _perl_5012_pragmas => {
109 deprecate => 1,
110 },
111 _perl_5010_pragmas => {
112 mro => 1,
113 feature => 1,
114 },
115 _perl_5010_operators => {
116 '//' => 1,
117 '//=' => 1,
118 '~~' => 1,
119 },
120 _perl_5010_magic => {
121 '%+' => 1,
122 '%-' => 1,
123 },
124 _perl_5008_pragmas => {
125 threads => 1,
126 'threads::shared' => 1,
127 sort => 1,
128 encoding => 1,
129 },
130 );
131 }
132  
133 sub PMV () { 'Perl::MinimumVersion' }
134  
135  
136  
137  
138  
139 #####################################################################
140 # Constructor
141  
142 =pod
143  
144 =head2 new
145  
146 # Create the version checking object
147 $object = Perl::MinimumVersion->new( $filename );
148 $object = Perl::MinimumVersion->new( \$source );
149 $object = Perl::MinimumVersion->new( $ppi_document );
150  
151 The C<new> constructor creates a new version checking object for a
152 L<PPI::Document>. You can also provide the document to be read as a
153 file name, or as a C<SCALAR> reference containing the code.
154  
155 Returns a new C<Perl::MinimumVersion> object, or C<undef> on error.
156  
157 =cut
158  
159 205 ▶sub new {
Subroutine new: called CC=4 SCAR=14.5
Pod documented
160 205 ▶ my $class = ref $_[0] ? ref shift : shift;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 205 205
161 205 ▶ my $Document = _Document(shift) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $Document = _Document(shift()) or return undef 202 3 205
162 202 ▶ my $default = _INSTANCE(shift, 'version') || version->new('5.006');
Condition33%1/3
&_INSTANCE(shift(), 'version') || 'version'->new('5.006')
l!l&&r!l&&!r
02020
MC/DC0%0/2
&_INSTANCE(shift(), 'version') || 'version'->new('5.006')
&_INSTANCE(shift(), 'version') 'version'->new('5.006')
Truth table33%1/3
A || B
A= &_INSTANCE(shift(), 'version')B= 'version'->new('5.006')
ABresult
1X1
011
000
163  
164 # Create the object
165 202 my $self = bless {
166 Document => $Document,
167  
168 # Checking limit and default minimum version.
169 # Explicitly don't check below this version.
170 default => $default,
171  
172 # Caches for resolved versions
173 explicit => undef,
174 syntax => undef,
175 external => undef,
176 }, $class;
177  
178 202 $self;
179 }
180  
181 =pod
182  
183 =head2 Document
184  
185 The C<Document> accessor can be used to get the L<PPI::Document> object
186 back out of the version checker.
187  
188 =cut
189  
190 1409 ▶sub Document {
Subroutine Document: called CC=1 SCAR=0.0
Pod documented
191 $_[0]->{Document}
192 1409 }
193  
194  
195  
196  
197  
198 #####################################################################
199 # Main Methods
200  
201 =pod
202  
203 =head2 minimum_version
204  
205 The C<minimum_version> method is the primary method for finding the
206 minimum perl version required based on C<all> factors in the document.
207  
208 At the present time, this is just syntax and explicit version checks,
209 as L<Perl::Depends> is not yet completed.
210  
211 Returns a L<version> object, or C<undef> on error.
212  
213 =cut
214  
215 56 ▶sub minimum_version {
Subroutine minimum_version: called CC=8 SCAR=21.1
Pod documented
216 56 ▶ my $self = _SELF(\@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $self = _SELF(\@_) or return undef 56 0 56
217 56 my $minimum = $self->{default}; # Sensible default
218  
219 # Is the explicit version greater?
220 56 my $explicit = $self->minimum_explicit_version;
221 56 ▶ return undef unless defined $explicit;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $explicit 0 56 56
222 56 ▶ if ( $explicit and $explicit > $minimum ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($explicit and $explicit > $minimum) 1 55 56
Condition100%3/3
$explicit and $explicit > $minimum
!ll&&!rl&&r
5411
MC/DC100%2/2
$explicit and $explicit > $minimum
$explicit $explicit > $minimum
Truth table100%3/3
A and B
A= $explicitB= $explicit > $minimum
ABresult
0X0
100
111
223 1 $minimum = $explicit;
224 }
225  
226 # Is the syntax version greater?
227 # Since this is the most expensive operation (for this file),
228 # we need to be careful we don't run things we don't need to.
229 56 my $syntax = $self->minimum_syntax_version;
230 56 ▶ return undef unless defined $syntax;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $syntax 0 56 56
231 56 ▶ if ( $syntax and $syntax > $minimum ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($syntax and $syntax > $minimum) 40 16 56
Condition66%2/3
$syntax and $syntax > $minimum
!ll&&!rl&&r
16040
MC/DC50%1/2
$syntax and $syntax > $minimum
$syntax $syntax > $minimum
Truth table66%2/3
A and B
A= $syntaxB= $syntax > $minimum
ABresult
0X0
100
111
232 40 $minimum = $syntax;
233 }
234  
235 ### FIXME - Disabled until minimum_external_version completed
236 # Is the external version greater?
237 #my $external = $self->minimum_external_version;
238 #return undef unless defined $external;
239 #if ( $external and $external > $minimum ) {
240 # $minimum = $external;
241 #}
242  
243 56 $minimum;
244 }
245  
246 0 ▶sub minimum_reason {
Subroutine minimum_reason: not called CC=5 SCAR=34.0
Pod undocumented
247 0 ▶ my $self = _SELF(\@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $self = _SELF(\@_) or return undef 0 0 0
248 0 my $minimum = $self->default_reason; # Sensible default
249  
250 # Is the explicit version greater?
251 0 my $explicit = $self->minimum_explicit_version;
252 0 ▶ return undef unless defined $explicit;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $explicit 0 0 0
253 0 ▶ if ( $explicit and $explicit > $minimum ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($explicit and $explicit > $minimum) 0 0 0
Condition0%0/3
$explicit and $explicit > $minimum
!ll&&!rl&&r
000
MC/DC0%0/2
$explicit and $explicit > $minimum
$explicit $explicit > $minimum
Truth table0%0/3
A and B
A= $explicitB= $explicit > $minimum
ABresult
0X0
100
111
254 0 $minimum = $explicit;
255 }
256  
257 }
258  
259 0 ▶sub default_reason {
Subroutine default_reason: not called CC=1 SCAR=6.9
Pod undocumented
260 Perl::MinimumVersion::Reason->new(
261 rule => 'default',
262 version => $_[0]->{default},
263 0 element => undef,
264 );
265 }
266  
267 =pod
268  
269 =head2 minimum_explicit_version
270  
271 The C<minimum_explicit_version> method checks through Perl code for the
272 use of explicit version dependencies such as.
273  
274 use 5.006;
275 require 5.005_03;
276  
277 Although there is almost always only one of these in a file, if more than
278 one are found, the highest version dependency will be returned.
279  
280 Returns a L<version> object, false if no dependencies could be found,
281 or C<undef> on error.
282  
283 =cut
284  
285 57 ▶sub minimum_explicit_version {
Subroutine minimum_explicit_version: called CC=3 SCAR=11.1
Pod documented
286 57 ▶ my $self = _SELF(\@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $self = _SELF(\@_) or return undef 57 0 57
287 57 my $reason = $self->minimum_explicit_reason(@_);
288 57 ▶ return $reason ? $reason->version : $reason;
Branch: 1 branch
BranchTrueFalseTotal
$reason ? : 3 54 57
289 }
290  
291 57 ▶sub minimum_explicit_reason {
Subroutine minimum_explicit_reason: called CC=3 SCAR=11.4
Pod undocumented
292 57 ▶ my $self = _SELF(\@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $self = _SELF(\@_) or return undef 57 0 57
293 57 ▶ unless ( defined $self->{explicit} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"explicit"}) 57 0 57
294 57 $self->{explicit} = $self->_minimum_explicit_version;
295 }
296 57 return $self->{explicit};
297 }
298  
299 57 ▶sub _minimum_explicit_version {
Subroutine _minimum_explicit_version: called CC=6 SCAR=18.0
300 57 ▶ my $self = shift or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return undef 57 0 57
301 591 ▶ my $explicit = $self->Document->find( sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
302 591 ▶ $_[1]->isa('PPI::Statement::Include') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Include") or return "" 25 566 591
303 25 ▶ $_[1]->version or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->version or return "" 4 21 25
304 4 1;
305 57 } );
306 57 ▶ return $explicit unless $explicit;
Branch: 1 branch
BranchTrueFalseTotal
unless $explicit 54 3 57
307  
308 # Find the highest version
309 3 my $max = undef;
310 3 my $element = undef;
311 3 foreach my $include ( @$explicit ) {
312 4 my $version = version->new($include->version);
313 4 ▶ if ( not $element or $version > $max ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $element or $version > $max) 4 0 4
Condition66%2/3
not $element or $version > $max
l!l&&r!l&&!r
310
MC/DC0%0/2
not $element or $version > $max
not $element $version > $max
Truth table66%2/3
not(A) or B
A= not $elementB= $version > $max
ABresult
1X1
011
000
314 4 $max = $version;
315 4 $element = $include;
316 }
317 }
318  
319 3 return Perl::MinimumVersion::Reason->new(
320 rule => 'explicit',
321 version => $max,
322 element => $element,
323 );
324 }
325  
326 =pod
327  
328 =head2 minimum_syntax_version $limit
329  
330 The C<minimum_syntax_version> method will explicitly test only the
331 Document's syntax to determine it's minimum version, to the extent
332 that this is possible.
333  
334 It takes an optional parameter of a L<version> object defining
335 the lowest known current value. For example, if it is already known
336 that it must be 5.006 or higher, then you can provide a param of
337 qv(5.006) and the method will not run any of the tests below this
338 version. This should provide dramatic speed improvements for
339 large and/or complex documents.
340  
341 The limitations of parsing Perl mean that this method may provide
342 artificially low results, but should not artificially high results.
343  
344 For example, if C<minimum_syntax_version> returned 5.006, you can be
345 confident it will not run on anything lower, although there is a chance
346 that during actual execution it may use some untestable feature that
347 creates a dependency on a higher version.
348  
349 Returns a L<version> object, false if no dependencies could be found,
350 or C<undef> on error.
351  
352 =cut
353  
354 62 ▶sub minimum_syntax_version {
Subroutine minimum_syntax_version: called CC=3 SCAR=11.1
Pod documented
355 62 ▶ my $self = _SELF(\@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $self = _SELF(\@_) or return undef 62 0 62
356 62 my $reason = $self->minimum_syntax_reason(@_);
357 62 ▶ return $reason ? $reason->version : $reason;
Branch: 1 branch
BranchTrueFalseTotal
$reason ? : 43 19 62
358 }
359  
360 65 ▶sub minimum_syntax_reason {
Subroutine minimum_syntax_reason: called CC=8 SCAR=20.8
Pod undocumented
361 65 ▶ my $self = _SELF(\@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $self = _SELF(\@_) or return undef 65 0 65
362 65 my $limit = shift;
363 65 ▶ if ( defined $limit and not _INSTANCE($limit, 'version') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $limit and not &_INSTANCE($limit, "version")) 1 64 65
Condition100%3/3
defined $limit and not &_INSTANCE($limit, "version")
!ll&&!rl&&r
6221
MC/DC100%2/2
defined $limit and not &_INSTANCE($limit, "version")
defined $limit not &_INSTANCE($limit, "version")
Truth table100%3/3
A and not(B)
A= defined $limitB= not &_INSTANCE($limit, "version")
ABresult
0X0
100
111
364 1 $limit = version->new("$limit");
365 }
366 65 ▶ if ( defined $self->{syntax} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"syntax"}) 5 60 65
367 5 ▶ if ( !defined($limit) or $self->{syntax}->version >= $limit ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $limit or $self->{"syntax"}->version >= $limit) 4 1 5
Condition100%3/3
not defined $limit or $self->{"syntax"}->version >= $limit
l!l&&r!l&&!r
311
MC/DC100%2/2
not defined $limit or $self->{"syntax"}->version >= $limit
not defined $limit $self->{"syntax"}->version >= $limit
Truth table100%3/3
not(A) or B
A= not defined $limitB= $self->{"syntax"}->version >= $limit
ABresult
1X1
011
000
368 # Previously discovered minimum is what they want
369 4 return $self->{syntax};
370 }
371  
372 # Rather than return a value BELOW their filter,
373 # which they would not be expecting, return false.
374 1 return '';
375 }
376  
377 # Look for the value
378 60 my $syntax = $self->_minimum_syntax_version( $limit );
379  
380 # If we found a value, it will be stable, cache it.
381 # If we did NOT, don't cache as subsequent runs without
382 # the filter may find a version.
383 60 ▶ if ( $syntax ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($syntax) 42 18 60
384 42 $self->{syntax} = $syntax;
385 42 return $self->{syntax};
386 }
387  
388 18 return '';
389 }
390  
391 #for Perl::Critic::Policy::Compatibility::PerlMinimumVersionAndWhy
392 1 ▶sub _set_checks2skip {
Subroutine _set_checks2skip: called CC=1 SCAR=0.0
393 1 my $self = shift;
394 1 my $list = shift;
395 1 $self->{_checks2skip} = $list;
396 }
397 1 ▶sub _set_collect_all_reasons {
Subroutine _set_collect_all_reasons: called CC=2 SCAR=7.0
398 1 my $self = shift;
399 1 my $value = shift;
400 1 ▶ $value = 1 unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 1 0 1
401 1 $self->{_collect_all_reasons} = $value;
402 }
403  
404 60 ▶sub _minimum_syntax_version {
Subroutine _minimum_syntax_version: called CC=12 SCAR=25.0
405 60 my $self = shift;
406 60 ▶ my $filter = shift || $self->{default};
Condition66%2/3
shift() || $self->{'default'}
l!l&&r!l&&!r
1590
MC/DC0%0/2
shift() || $self->{'default'}
shift() $self->{'default'}
Truth table66%2/3
A || B
A= shift()B= $self->{'default'}
ABresult
1X1
011
000
407  
408 60 my %checks2skip;
409 60 ▶ @checks2skip{ @{ $self->{_checks2skip} || [] } } = ();
Condition100%2/2
$self->{'_checks2skip'} || []
l!l
159
MC/DC100%1/1
$self->{'_checks2skip'} || []
$self->{'_checks2skip'}
Truth table100%2/2
A
A= $self->{'_checks2skip'}
Aresult
11
00
410  
411 60 my %rv_result;
412 my $current_reason;
413 60 foreach my $rule ( @CHECKS_RV ) {
414 420 ▶ next if exists $checks2skip{$rule};
Branch: 1 branch
BranchTrueFalseTotal
if exists $checks2skip{$rule} 1 419 420
415 419 my ($v, $obj) = $self->$rule();
416 419 $v = version->new($v);
417 419 ▶ if ( $v > $filter ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v > $filter) 19 400 419
418 19 $current_reason = Perl::MinimumVersion::Reason->new(
419 rule => $rule,
420 version => $v,
421 element => _INSTANCE($obj, 'PPI::Element'),
422 );
423 19 ▶ if ($self->{_collect_all_reasons}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_collect_all_reasons'}) { } 1 18 19
424 1 push @{ $self->{_all_reasons} }, $current_reason;
425 } else {
426 18 $filter = $v;
427 }
428 }
429 }
430  
431  
432 # Always check in descending version order.
433 # By doing it this way, the version of the first check that matches
434 # is also the version of the document as a whole.
435 my @rules = sort {
436 3269 $CHECKS{$b} <=> $CHECKS{$a}
437 } grep {
438 60 ▶ not(exists $checks2skip{$_}) and $CHECKS{$_} > $filter
Condition66%2/3
!exists $checks2skip{$_} && $Perl::MinimumVersion::CHECKS{$_} > $filter
!ll&&!rl&&r
03281052
MC/DC50%1/2
!exists $checks2skip{$_} && $Perl::MinimumVersion::CHECKS{$_} > $filter
!exists $checks2skip{$_} $Perl::MinimumVersion::CHECKS{$_} > $filter
Truth table66%2/3
not(A) && B
A= !exists $checks2skip{$_}B= $Perl::MinimumVersion::CHECKS{$_} > $filter
ABresult
0X0
100
111
439 } keys %CHECKS;
440  
441 60 foreach my $rule ( @rules ) {
442 700 ▶ my $result = $self->$rule() or next;
Branch: 1 branch
BranchTrueFalseTotal
my $result = $self->$rule or next 25 675 700
443  
444 # Create the result object
445 my $reason = Perl::MinimumVersion::Reason->new(
446 rule => $rule,
447 25 version => $CHECKS{$rule},
448 element => _INSTANCE($result, 'PPI::Element'),
449 );
450 25 ▶ if ($self->{_collect_all_reasons}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_collect_all_reasons'}) { } 0 25 25
451 0 push @{ $self->{_all_reasons} }, $current_reason;
452 } else {
453 25 return $reason;
454 }
455  
456 }
457  
458 # Found nothing of interest
459 35 ▶ return $current_reason || '';
Condition100%2/2
$current_reason || ''
l!l
1718
MC/DC100%1/1
$current_reason || ''
$current_reason
Truth table100%2/2
A
A= $current_reason
Aresult
11
00
460 }
461  
462 =pod
463  
464 =head2 minimum_external_version
465  
466 B<WARNING: This method has not been implemented. Any attempted use will throw
467 an exception>
468  
469 The C<minimum_external_version> examines code for dependencies on other
470 external files, and recursively traverses the dependency tree applying the
471 same tests to those files as it does to the original.
472  
473 Returns a C<version> object, false if no dependencies could be found, or
474 C<undef> on error.
475  
476 =cut
477  
478 0 ▶sub minimum_external_version {
Subroutine minimum_external_version: not called CC=3 SCAR=24.8
Pod documented
479 0 ▶ my $self = _SELF(\@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $self = _SELF(\@_) or return undef 0 0 0
480 0 my $reason = $self->minimum_explicit_reason(@_);
481 0 ▶ return $reason ? $reason->version : $reason;
Branch: 1 branch
BranchTrueFalseTotal
$reason ? : 0 0 0
482 }
483  
484 0 ▶sub minimum_external_reason {
Subroutine minimum_external_reason: not called CC=3 SCAR=24.8
Pod undocumented
485 0 ▶ my $self = _SELF(\@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $self = _SELF(\@_) or return undef 0 0 0
486 0 ▶ unless ( defined $self->{external} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"external"}) 0 0 0
487 0 $self->{external} = $self->_minimum_external_version;
488 }
489 0 $self->{external};
490 }
491  
492 0 ▶sub _minimum_external_version {
Subroutine _minimum_external_version: not called CC=1 SCAR=6.9
493 0 Carp::croak("Perl::MinimumVersion::minimum_external_version is not implemented");
494 }
495  
496 =pod
497  
498 =head2 version_markers
499  
500 This method returns a list of pairs in the form:
501  
502 ($version, \@markers)
503  
504 Each pair represents all the markers that could be found indicating that the
505 version was the minimum needed version. C<@markers> is an array of strings.
506 Currently, these strings are not as clear as they might be, but this may be
507 changed in the future. In other words: don't rely on them as specific
508 identifiers.
509  
510 =cut
511  
512 1 ▶sub version_markers {
Subroutine version_markers: called CC=7 SCAR=19.6
Pod documented
513 1 ▶ my $self = _SELF(\@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $self = _SELF(\@_) or return undef 1 0 1
514  
515 1 my %markers;
516  
517 1 ▶ if ( my $explicit = $self->minimum_explicit_version ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $explicit = $self->minimum_explicit_version) 1 0 1
518 1 $markers{ $explicit } = [ 'explicit' ];
519 }
520  
521 1 foreach my $check ( keys %CHECKS ) {
522 23 ▶ next unless $self->$check();
Branch: 1 branch
BranchTrueFalseTotal
unless $self->$check 22 1 23
523 1 ▶ my $markers = $markers{ $CHECKS{$check} } ||= [];
Condition50%1/2
$markers{$Perl::MinimumVersion::CHECKS{$check}} ||= []
l!l
01
MC/DC0%0/1
$markers{$Perl::MinimumVersion::CHECKS{$check}} ||= []
$markers{$Perl::MinimumVersion::CHECKS{$check}}
Truth table50%1/2
A
A= $markers{$Perl::MinimumVersion::CHECKS{$check}}
Aresult
11
00
524 1 push @$markers, $check;
525 }
526  
527 1 my @rv;
528 1 my %marker_ver = map { $_ => version->new($_) } keys %markers;
529  
530 1 foreach my $ver ( sort { $marker_ver{$b} <=> $marker_ver{$a} } keys %markers ) {
531 2 push @rv, $marker_ver{$ver} => $markers{$ver};
532 }
533  
534 1 return @rv;
535 }
536  
537  
538  
539  
540 #####################################################################
541 # Version Check Methods
542  
543 21 my %feature =
544 (
545 'say' => '5.10',
546 'smartmatch' => '5.10',
547 'state' => '5.10',
548 'switch' => '5.10',
549 'unicode_strings' => '5.14',
550 'unicode_eval' => '5.16',
551 'evalbytes' => '5.16',
552 'current_sub' => '5.16',
553 'array_base' => '5.16', #defined only in 5.16
554 'fc' => '5.16',
555 'lexical_subs' => '5.18',
556 'postderef' => '5.20',
557 'postderef_qq' => '5.20',
558 'signatures' => '5.20',
559 'refaliasing' => '5.22',
560 'bitwise' => '5.22',
561 'declared_refs' => '5.26',
562 'isa' => '5.32',
563 'indirect' => '5.32', #defined only in 5.32
564 );
565 21 my $feature_regexp = join('|', keys %feature);
566  
567 #:5.14 means same as :5.12, but :5.14 is not defined in feature.pm in perl 5.12.
568 84 ▶sub _feature_bundle {
Subroutine _feature_bundle: called CC=2 SCAR=6.9
569 84 my @versions;
570 84 my ($version, $obj);
571 772 ▶ shift->Document->find( sub {
Subroutine __ANON__: called CC=9 SCAR=22.0
572 772 ▶ $_[1]->isa('PPI::Statement::Include') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Include") or return "" 49 723 772
573 49 ▶ $_[1]->pragma eq 'feature' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->pragma eq "feature" or return "" 31 18 49
574 31 my @child = $_[1]->schildren;
575 31 my @args = @child[1..$#child]; # skip 'use', 'feature' and ';'
576 31 foreach my $arg (@args) {
577 92 my $v = 0;
578 92 ▶ $v = $1 if ($arg->content =~ /:(5\.\d+)(?:\.\d+)?/);
Branch: 1 branch
BranchTrueFalseTotal
if $arg->content =~ /:(5\.\d+)(?:\.\d+)?/ 11 81 92
579 92 ▶ $v = max($v, $feature{$1}) if ($arg->content =~ /\b($feature_regexp)\b/);
Branch: 1 branch
BranchTrueFalseTotal
if $arg->content =~ /\b($feature_regexp)\b/ 20 72 92
580 #
581 92 ▶ if ($v and $v > ($version || 0) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v and $v > ($version || 0)) 29 63 92
Condition100%5/5
$v and $v > ($version || 0)
!ll&&!rl&&r
61229
$version || 0
l!l
328
MC/DC100%2/2
$v and $v > ($version || 0)
$v $v > ($version || 0)
MC/DC100%1/1
$version || 0
$version
Truth table100%3/3
A and B
A= $vB= $v > ($version || 0)
ABresult
0X0
100
111
Truth table100%2/2
A
A= $version
Aresult
11
00
582 29 $version = $v;
583 29 $obj = $_[1];
584 }
585 }
586 31 return '';
587 84 } );
588 84 ▶ return (defined($version)?"$version.0":undef, $obj);
Branch: 1 branch
BranchTrueFalseTotal
defined $version ? : 28 56 84
589 }
590  
591 # list copied from experimental.pm v0.021 itself
592 21 my %experimental =
593 (
594 array_base => '5',
595 autoderef => '5.14',
596 bitwise => '5.22',
597 const_attr => '5.22',
598 current_sub => '5.16',
599 declared_refs => '5.26',
600 evalbytes => '5.16',
601 fc => '5.16',
602 isa => '5.32',
603 lexical_topic => '5.10',
604 lexical_subs => '5.18',
605 postderef => '5.20',
606 postderef_qq => '5.20',
607 refaliasing => '5.22',
608 regex_sets => '5.18',
609 say => '5.10',
610 smartmatch => '5.10',
611 signatures => '5.20',
612 state => '5.10',
613 switch => '5.10',
614 unicode_eval => '5.16',
615 unicode_strings => '5.12',
616 );
617 21 my $experimental_regexp = join('|', keys %experimental);
618 60 ▶sub _experimental_bundle {
Subroutine _experimental_bundle: called CC=2 SCAR=6.9
619 60 my ($version, $obj);
620  
621 591 ▶ shift->Document->find( sub {
Subroutine __ANON__: called CC=9 SCAR=22.1
622 591 ▶ return '' unless $_[1]->isa('PPI::Statement::Include')
Branch: 1 branch
BranchTrueFalseTotal
unless $_[1]->isa("PPI::Statement::Include") and $_[1]->pragma eq "experimental" 589 2 591
Condition100%3/3
$_[1]->isa("PPI::Statement::Include") and $_[1]->pragma eq "experimental"
!ll&&!rl&&r
568212
MC/DC100%2/2
$_[1]->isa("PPI::Statement::Include") and $_[1]->pragma eq "experimental"
$_[1]->isa("PPI::Statement::Include") $_[1]->pragma eq "experimental"
Truth table100%3/3
A and B
A= $_[1]->isa("PPI::Statement::Include")B= $_[1]->pragma eq "experimental"
ABresult
0X0
100
111
623 and $_[1]->pragma eq 'experimental';
624  
625 2 my @child = $_[1]->schildren;
626 2 my @args = @child[1..$#child]; # skip 'use', 'experimental' and ';'
627 2 foreach my $arg (@args) {
628 5 my $v = 0;
629 5 ▶ $v = $1 if ($arg->content =~ /:(5\.\d+)(?:\.\d+)?/);
Branch: 1 branch
BranchTrueFalseTotal
if $arg->content =~ /:(5\.\d+)(?:\.\d+)?/ 0 5 5
630 5 ▶ $v = max($v, $experimental{$1}) if ($arg->content =~ /\b($experimental_regexp)\b/);
Branch: 1 branch
BranchTrueFalseTotal
if $arg->content =~ /\b($experimental_regexp)\b/ 1 4 5
631  
632 5 ▶ if ($v and $v > ($version || 0) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v and $v > ($version || 0)) 1 4 5
Condition60%3/5
$v and $v > ($version || 0)
!ll&&!rl&&r
401
$version || 0
l!l
01
MC/DC50%1/2
$v and $v > ($version || 0)
$v $v > ($version || 0)
MC/DC0%0/1
$version || 0
$version
Truth table66%2/3
A and B
A= $vB= $v > ($version || 0)
ABresult
0X0
100
111
Truth table50%1/2
A
A= $version
Aresult
11
00
633 1 $version = $v;
634 1 $obj = $_[1];
635 }
636 }
637 2 return '';
638 60 } );
639  
640 60 ▶ return (defined($version)?"$version.0":undef, $obj);
Branch: 1 branch
BranchTrueFalseTotal
defined $version ? : 1 59 60
641 }
642  
643 21 my %SCHEDULED_BLOCK =
644 (
645 'INIT' => '5.006',
646 'CHECK' => '5.006002',
647 'UNITCHECK' => '5.010',
648 );
649  
650 sub _scheduled_blocks
651 60 ▶{
Subroutine _scheduled_blocks: called CC=2 SCAR=7.0
652 60 my @versions;
653 60 my ($version, $obj);
654  
655 591 ▶ shift->Document->find( sub {
Subroutine __ANON__: called CC=7 SCAR=20.2
656 591 ▶ $_[1]->isa('PPI::Statement::Scheduled') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Scheduled") or return "" 4 587 591
657 4 ▶ ($_[1]->children)[0]->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
($_[1]->children)[0]->isa("PPI::Token::Word") or return "" 4 0 4
658 4 my $function = (($_[1]->children)[0])->content;
659 4 ▶ exists( $SCHEDULED_BLOCK{ $function }) or return '';
Branch: 1 branch
BranchTrueFalseTotal
exists $SCHEDULED_BLOCK{$function} or return "" 3 1 4
660  
661 3 my $v = $SCHEDULED_BLOCK{ ($_[1]->children)[0]->content };
662 3 ▶ if ($v and $v > ($version || 0) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v and $v > ($version || 0)) 3 0 3
Condition40%2/5
$v and $v > ($version || 0)
!ll&&!rl&&r
003
$version || 0
l!l
03
MC/DC0%0/2
$v and $v > ($version || 0)
$v $v > ($version || 0)
MC/DC0%0/1
$version || 0
$version
Truth table33%1/3
A and B
A= $vB= $v > ($version || 0)
ABresult
0X0
100
111
Truth table50%1/2
A
A= $version
Aresult
11
00
663 3 $version = $v;
664 3 $obj = $_[1];
665 }
666  
667 3 return '';
668 60 } );
669 60 ▶ return (defined($version) ? $version : undef, $obj);
Branch: 1 branch
BranchTrueFalseTotal
defined $version ? : 3 57 60
670 }
671  
672 68 ▶sub _regex {
Subroutine _regex: called CC=3 SCAR=11.2
673 68 my $self = shift;
674 68 my @versions;
675 68 my ($version, $obj);
676 606 ▶ $self->Document->find( sub {
Subroutine __ANON__: called CC=5 SCAR=16.7
677 return '' unless
678 606 ▶ grep { $_[1]->isa($_) }
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_[1]->isa($_);} "PPI::Token::QuoteLike::Regexp", "PPI::Token::Regexp::Match", "PPI::Token::Regexp::Substitute" 593 13 606
679 qw/PPI::Token::QuoteLike::Regexp PPI::Token::Regexp::Match PPI::Token::Regexp::Substitute/;
680 13 my $re = PPIx::Regexp->new( $_[1] );
681 13 my $v = $re->perl_version_introduced;
682 13 ▶ if ($v and $v > ($version || 0) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v and $v > ($version || 0)) 13 0 13
Condition40%2/5
$v and $v > ($version || 0)
!ll&&!rl&&r
0013
$version || 0
l!l
013
MC/DC0%0/2
$v and $v > ($version || 0)
$v $v > ($version || 0)
MC/DC0%0/1
$version || 0
$version
Truth table33%1/3
A and B
A= $vB= $v > ($version || 0)
ABresult
0X0
100
111
Truth table50%1/2
A
A= $version
Aresult
11
00
683 13 $version = $v;
684 13 $obj = $_[1];
685 }
686 13 return '';
687 68 } );
688 68 my $tr_r_version = version->new('5.013.007');
689 606 ▶ $self->Document->find( sub {
Subroutine __ANON__: called CC=5 SCAR=17.2
690 606 ▶ return '' unless
Branch: 1 branch
BranchTrueFalseTotal
unless $_[1]->isa("PPI::Token::Regexp::Transliterate") 604 2 606
691 $_[1]->isa(q/PPI::Token::Regexp::Transliterate/);
692 2 ▶ if( exists $_[1]->get_modifiers->{r}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_[1]->get_modifiers->{"r"} and $tr_r_version > ($version || 0)) 2 0 2
Condition40%2/5
exists $_[1]->get_modifiers->{"r"} and $tr_r_version > ($version || 0)
!ll&&!rl&&r
002
$version || 0
l!l
02
MC/DC0%0/2
exists $_[1]->get_modifiers->{"r"} and $tr_r_version > ($version || 0)
exists $_[1]->get_modifiers->{"r"} $tr_r_version > ($version || 0)
MC/DC0%0/1
$version || 0
$version
Truth table33%1/3
A and B
A= exists $_[1]->get_modifiers->{"r"}B= $tr_r_version > ($version || 0)
ABresult
0X0
100
111
Truth table50%1/2
A
A= $version
Aresult
11
00
693 && $tr_r_version > ( $version || 0 )
694 ) {
695 2 $version = $tr_r_version;
696 2 $obj = $_[1];
697 }
698 2 return '';
699 68 } );
700 68 ▶ $version = undef if ($version and $version eq '5.000');
Branch: 1 branch
BranchTrueFalseTotal
if $version and $version eq "5.000" 3 65 68
Condition100%3/3
$version and $version eq "5.000"
!ll&&!rl&&r
53123
MC/DC100%2/2
$version and $version eq "5.000"
$version $version eq "5.000"
Truth table100%3/3
A and B
A= $versionB= $version eq "5.000"
ABresult
0X0
100
111
701 68 return ($version, $obj);
702 }
703  
704 # Check for use re "/flags";
705 60 ▶sub _re_flags {
Subroutine _re_flags: called CC=3 SCAR=11.1
706 60 my ($version, $obj);
707 586 ▶ shift->Document->find( sub {
Subroutine __ANON__: called CC=9 SCAR=22.3
708 586 ▶ return '' unless $_[1]->isa('PPI::Statement::Include')
Branch: 1 branch
BranchTrueFalseTotal
unless $_[1]->isa("PPI::Statement::Include") and $_[1]->module eq "re" || $_[1]->pragma eq "re" 577 9 586
Condition83%5/6
$_[1]->isa("PPI::Statement::Include") and $_[1]->module eq "re" || $_[1]->pragma eq "re"
!ll&&!rl&&r
563149
$_[1]->module eq "re" or $_[1]->pragma eq "re"
l!l&&r!l&&!r
9014
MC/DC66%2/3
$_[1]->isa("PPI::Statement::Include") and $_[1]->module eq "re" || $_[1]->pragma eq "re"
$_[1]->isa("PPI::Statement::Include") $_[1]->module eq "re" $_[1]->pragma eq "re"
Truth table75%3/4
A and B or C
A= $_[1]->isa("PPI::Statement::Include")B= $_[1]->module eq "re"C= $_[1]->pragma eq "re"
ABCresult
0XX0
1000
11X1
1011
709 and ($_[1]->module eq 're' or $_[1]->pragma eq 're');
710 9 my $included = $_[1]->schild(2);
711 9 ▶ my @literal = $included->can('literal') ? $included->literal() : $included->string();
Branch: 1 branch
BranchTrueFalseTotal
$included->can('literal') ? : 4 5 9
712 8 my $v = "5.005";
713 8 my @flags = grep {index($_, '/') == 0} @literal;
714 8 ▶ $v = '5.014' if @flags;
Branch: 1 branch
BranchTrueFalseTotal
if @flags 7 1 8
715 $v = max $v, map {
716 8 my $empty_regex_w_flag = "/$_";
717 8 PPIx::Regexp->new( $empty_regex_w_flag )->perl_version_introduced;
718 } @flags;
719 8 ▶ if ($v and $v > ($version || 0) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v and $v > ($version || 0)) 8 0 8
Condition40%2/5
$v and $v > ($version || 0)
!ll&&!rl&&r
008
$version || 0
l!l
08
MC/DC0%0/2
$v and $v > ($version || 0)
$v $v > ($version || 0)
MC/DC0%0/1
$version || 0
$version
Truth table33%1/3
A and B
A= $vB= $v > ($version || 0)
ABresult
0X0
100
111
Truth table50%1/2
A
A= $version
Aresult
11
00
720 8 $version = $v;
721 8 $obj = $_[1];
722 }
723  
724 60 } );
725 60 ▶ $version = undef if ($version and $version eq '5.000');
Branch: 1 branch
BranchTrueFalseTotal
if $version and $version eq "5.000" 0 60 60
Condition66%2/3
$version and $version eq "5.000"
!ll&&!rl&&r
5280
MC/DC0%0/2
$version and $version eq "5.000"
$version $version eq "5.000"
Truth table66%2/3
A and B
A= $versionB= $version eq "5.000"
ABresult
0X0
100
111
726 60 return ($version, $obj);
727 }
728  
729 102 ▶sub _each_argument {
Subroutine _each_argument: called CC=2 SCAR=7.0
730 102 my ($version, $obj);
731 899 ▶ shift->Document->find( sub {
Subroutine __ANON__: called CC=25 SCAR=33.1
732 899 ▶ $_[1]->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Word") or return "" 128 771 899
733 128 ▶ $_[1]->content =~ '^(each|keys|values)$' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->content =~ /^(each|keys|values)$/ or return "" 44 84 128
734 44 ▶ return '' if is_method_call($_[1]);
Branch: 1 branch
BranchTrueFalseTotal
if is_method_call($_[1]) 2 42 44
735 42 my $next = $_[1]->snext_sibling;
736 42 ▶ $next = $next->schild(0)->schild(0) if $next->isa('PPI::Structure::List');
Branch: 1 branch
BranchTrueFalseTotal
if $next->isa("PPI::Structure::List") 16 25 41
737 41 ▶ if($next->isa('PPI::Token::Cast')) {
Branch: 4 branches
BranchTrueFalseTotal
if ($next->isa('PPI::Token::Cast')) { } 4 37 41
elsif ($next->isa('PPI::Token::Symbol')) { } 28 9 37
elsif ($next->isa('PPI::Token::Operator')) { } 1 8 9
elsif ($_[1]->parent->isa('PPI::Statement::Sub')) { } 2 6 8
738 4 ▶ if($next->content eq '@' && 5.012 > ($version || 0)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($next->content eq '@' and 5.012 > ($version || 0)) { } 3 1 4
elsif ($next->content eq '$' and 5.014 > ($version || 0)) { } 0 2 2
Condition60%3/5
$next->content eq "\@" and "5.012" > ($version || 0)
!ll&&!rl&&r
103
$version || 0
l!l
03
MC/DC50%1/2
$next->content eq "\@" and "5.012" > ($version || 0)
$next->content eq "\@" "5.012" > ($version || 0)
MC/DC0%0/1
$version || 0
$version
Truth table66%2/3
A and B
A= $next->content eq "\@"B= "5.012" > ($version || 0)
ABresult
0X0
100
111
Truth table50%1/2
A
A= $version
Aresult
11
00
739 3 $version = 5.012;
740 3 $obj = $_[1]->parent;
741 ▶ } elsif($next->content eq '$' && 5.014 > ($version || 0)) {
Condition20%1/5
$next->content eq "\$" and "5.014" > ($version || 0)
!ll&&!rl&&r
100
$version || 0
l!l
00
MC/DC0%0/2
$next->content eq "\$" and "5.014" > ($version || 0)
$next->content eq "\$" "5.014" > ($version || 0)
MC/DC0%0/1
$version || 0
$version
Truth table33%1/3
A and B
A= $next->content eq "\$"B= "5.014" > ($version || 0)
ABresult
0X0
100
111
Truth table0%0/2
A
A= $version
Aresult
11
00
742 0 $version = 5.014;
743 0 $obj = $_[1]->parent;
744 }
745 } elsif($next->isa('PPI::Token::Symbol')) {
746 28 ▶ if($next->raw_type eq '@' && 5.012 > ($version || 0)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($next->raw_type eq '@' and 5.012 > ($version || 0)) { } 7 21 28
elsif ($next->raw_type eq '$' and 5.014 > ($version || 0)) { } 14 14 28
Condition100%5/5
$next->raw_type eq "\@" and "5.012" > ($version || 0)
!ll&&!rl&&r
2017
$version || 0
l!l
17
MC/DC100%2/2
$next->raw_type eq "\@" and "5.012" > ($version || 0)
$next->raw_type eq "\@" "5.012" > ($version || 0)
MC/DC100%1/1
$version || 0
$version
Truth table100%3/3
A and B
A= $next->raw_type eq "\@"B= "5.012" > ($version || 0)
ABresult
0X0
100
111
Truth table100%2/2
A
A= $version
Aresult
11
00
747 7 $version = 5.012;
748 7 $obj = $_[1]->parent;
749 ▶ } elsif($next->raw_type eq '$' && 5.014 > ($version || 0)) {
Condition80%4/5
$next->raw_type eq "\$" and "5.014" > ($version || 0)
!ll&&!rl&&r
7014
$version || 0
l!l
113
MC/DC50%1/2
$next->raw_type eq "\$" and "5.014" > ($version || 0)
$next->raw_type eq "\$" "5.014" > ($version || 0)
MC/DC100%1/1
$version || 0
$version
Truth table66%2/3
A and B
A= $next->raw_type eq "\$"B= "5.014" > ($version || 0)
ABresult
0X0
100
111
Truth table100%2/2
A
A= $version
Aresult
11
00
750 14 $version = 5.014;
751 14 $obj = $_[1]->parent;
752 }
753 } elsif($next->isa('PPI::Token::Operator')) { # % $a
754 1 return '';
755 } elsif($_[1]->parent->isa('PPI::Statement::Sub')) { # sub each|keys|values
756 2 return '';
757 } else { # function call or other should be reference
758 6 ▶ if(5.014 > ($version || 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ("5.014" > ($version || 0)) 6 0 6
Condition50%1/2
$version || 0
l!l
06
MC/DC0%0/1
$version || 0
$version
Truth table50%1/2
A
A= $version
Aresult
11
00
759 6 $version = 5.014;
760 6 $obj = $_[1]->parent;
761 }
762 }
763 38 ▶ return 1 if ($version and $version == 5.014);
Branch: 1 branch
BranchTrueFalseTotal
if $version and $version == "5.014" 21 17 38
Condition100%3/3
$version and $version == "5.014"
!ll&&!rl&&r
71021
MC/DC100%2/2
$version and $version == "5.014"
$version $version == "5.014"
Truth table100%3/3
A and B
A= $versionB= $version == "5.014"
ABresult
0X0
100
111
764 17 return '';
765 102 } );
766 102 ▶ return (defined($version)?"$version":undef, $obj);
Branch: 1 branch
BranchTrueFalseTotal
defined $version ? : 29 73 102
767 }
768  
769 #Is string (first argument) in list (other arguments)
770 7 ▶sub _str_in_list {
Subroutine _str_in_list: called CC=3 SCAR=11.0
771 7 my $str = shift;
772 7 foreach my $s (@_) {
773 11 ▶ return 1 if $s eq $str;
Branch: 1 branch
BranchTrueFalseTotal
if $s eq $str 3 8 11
774 }
775 4 return 0;
776 }
777  
778  
779 69 ▶sub _binmode_2_arg {
Subroutine _binmode_2_arg: called CC=1 SCAR=0.0
780 69 my ($version, $obj);
781 663 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=13 SCAR=25.9
782 663 my $main_element=$_[1];
783 663 ▶ $main_element->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$main_element->isa("PPI::Token::Word") or return "" 82 581 663
784 82 ▶ $main_element->content eq 'binmode' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$main_element->content eq "binmode" or return "" 10 72 82
785 10 ▶ return '' if is_hash_key($main_element);
Branch: 1 branch
BranchTrueFalseTotal
if is_hash_key($main_element) 0 10 10
786 10 ▶ return '' if is_method_call($main_element);
Branch: 1 branch
BranchTrueFalseTotal
if is_method_call($main_element) 0 10 10
787 10 ▶ return '' if is_subroutine_name($main_element);
Branch: 1 branch
BranchTrueFalseTotal
if is_subroutine_name($main_element) 0 10 10
788 10 ▶ return '' if is_included_module_name($main_element);
Branch: 1 branch
BranchTrueFalseTotal
if is_included_module_name($main_element) 0 10 10
789 10 ▶ return '' if is_package_declaration($main_element);
Branch: 1 branch
BranchTrueFalseTotal
if is_package_declaration($main_element) 0 10 10
790 10 my @arguments = parse_arg_list($main_element);
791 10 ▶ if ( scalar @arguments == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @arguments == 2) 8 2 10
792 8 my $arg2=$arguments[1][0];
793 8 ▶ if ( $arg2->isa('PPI::Token::Quote')) { #check second argument
Branch: 1 branch
BranchTrueFalseTotal
if ($arg2->isa("PPI::Token::Quote")) 7 1 8
794 7 my $str = $arg2->string;
795 7 $str =~ s/^\s+//s;
796 7 $str =~ s/\s+$//s;
797 7 $str =~ s/:\s+/:/g;
798 7 ▶ if ( !_str_in_list( $str => qw/:raw :crlf/) and $str !~ /[\$\@\%]/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (_str_in_list($str, (":raw", ":crlf")) or $str =~ /[\$\@\%]/) 3 4 7
Condition100%3/3
_str_in_list($str, (":raw", ":crlf")) or $str =~ /[\$\@\%]/
l!l&&r!l&&!r
313
MC/DC100%2/2
_str_in_list($str, (":raw", ":crlf")) or $str =~ /[\$\@\%]/
_str_in_list($str, (":raw", ":crlf")) $str =~ /[\$\@\%]/
Truth table100%3/3
A or B
A= _str_in_list($str, (":raw", ":crlf"))B= $str =~ /[\$\@\%]/
ABresult
1X1
011
000
799 3 $version = 5.008;
800 3 $obj = $main_element;
801 3 return 1;
802 }
803 }
804 5 ▶ if (!$version) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($version) 5 0 5
805 5 $version = 5.006;
806 5 $obj = $main_element;
807 }
808 }
809 7 return '';
810 69 } );
811 69 return ($version, $obj);
812 }
813  
814  
815  
816 #http://perldoc.perl.org/functions/readdir.html
817 #while(readdir $dh) requires perl 5.12
818 44 ▶sub _while_readdir {
Subroutine _while_readdir: called CC=1 SCAR=0.0
819 474 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=14 SCAR=26.9
820 474 ▶ $_[1]->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Word") or return "" 59 415 474
821 59 ▶ $_[1]->content eq 'while' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->content eq "while" or return "" 8 51 59
822 8 ▶ return '' if is_hash_key($_[1]);
Branch: 1 branch
BranchTrueFalseTotal
if is_hash_key($_[1]) 0 8 8
823 8 ▶ return '' if is_method_call($_[1]);
Branch: 1 branch
BranchTrueFalseTotal
if is_method_call($_[1]) 0 8 8
824 8 ▶ my $e1 = $_[1]->next_sibling or return '';
Branch: 1 branch
BranchTrueFalseTotal
my $e1 = $_[1]->next_sibling or return "" 7 1 8
825 7 ▶ if ($e1->isa('PPI::Structure::Condition')) { #while ()
Branch: 1 branch
BranchTrueFalseTotal
if ($e1->isa("PPI::Structure::Condition")) 7 0 7
826 7 my @children = $e1->children;
827 7 $e1 = $children[0];
828 }
829 7 ▶ $e1->isa('PPI::Statement::Expression') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$e1->isa("PPI::Statement::Expression") or return "" 7 0 7
830 7 my @children = $e1->schildren;
831 7 $e1 = $children[0];
832  
833 7 ▶ $e1->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$e1->isa("PPI::Token::Word") or return "" 6 1 7
834 6 ▶ $e1->content eq 'readdir' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$e1->content eq "readdir" or return "" 5 1 6
835 5 ▶ return 1 if @children == 1; #incorrect call
Branch: 1 branch
BranchTrueFalseTotal
if @children == 1 0 5 5
836 5 ▶ return '' if @children > 2; #not only readdir
Branch: 1 branch
BranchTrueFalseTotal
if @children > 2 2 3 5
837 3 $e1 = $children[1];
838 3 ▶ $e1->isa('PPI::Structure::List') or $e1->isa('PPI::Token::Symbol') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$e1->isa("PPI::Structure::List") or $e1->isa("PPI::Token::Symbol") or return "" 3 0 3
Condition66%2/3
$e1->isa("PPI::Structure::List") or $e1->isa("PPI::Token::Symbol")
l!l&&r!l&&!r
120
MC/DC0%0/2
$e1->isa("PPI::Structure::List") or $e1->isa("PPI::Token::Symbol")
$e1->isa("PPI::Structure::List") $e1->isa("PPI::Token::Symbol")
Truth table66%2/3
A or B
A= $e1->isa("PPI::Structure::List")B= $e1->isa("PPI::Token::Symbol")
ABresult
1X1
011
000
839 #readdir($dh) or readdir $dh
840  
841 3 return 1;
842 44 } );
843 }
844  
845 36 ▶sub _perl_5012_pragmas {
Subroutine _perl_5012_pragmas: called CC=1 SCAR=0.0
846 312 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
847 $_[1]->isa('PPI::Statement::Include')
848 and
849 312 ▶ $MATCHES{_perl_5012_pragmas}->{$_[1]->pragma}
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Include") and $MATCHES{"_perl_5012_pragmas"}{$_[1]->pragma} 13 299 312
850 36 } );
851 }
852  
853 27 ▶sub _open_temp {
Subroutine _open_temp: called CC=1 SCAR=0.0
854 293 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=8 SCAR=20.8
855 293 ▶ $_[1]->isa('PPI::Statement') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement") or return "" 43 250 293
856 43 my @children = $_[1]->children;
857 #@children >= 7 or return '';
858 43 my $main_element = $children[0];
859 43 ▶ $main_element->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$main_element->isa("PPI::Token::Word") or return "" 25 18 43
860 25 ▶ $main_element->content eq 'open' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$main_element->content eq "open" or return "" 7 18 25
861 7 my @arguments = parse_arg_list($main_element);
862 7 ▶ if ( scalar @arguments == 3 and scalar(@{$arguments[2]}) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @arguments == 3 and scalar @{$arguments[2];} == 1) 5 2 7
Condition66%2/3
scalar @arguments == 3 and scalar @{$arguments[2];} == 1
!ll&&!rl&&r
205
MC/DC50%1/2
scalar @arguments == 3 and scalar @{$arguments[2];} == 1
scalar @arguments == 3 scalar @{$arguments[2];} == 1
Truth table66%2/3
A and B
A= scalar @arguments == 3B= scalar @{$arguments[2];} == 1
ABresult
0X0
100
111
863 5 my $arg3 = $arguments[2][0];
864 5 ▶ if ($arg3->isa('PPI::Token::Word') and $arg3->content eq 'undef') {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg3->isa("PPI::Token::Word") and $arg3->content eq "undef") 3 2 5
Condition66%2/3
$arg3->isa("PPI::Token::Word") and $arg3->content eq "undef"
!ll&&!rl&&r
203
MC/DC50%1/2
$arg3->isa("PPI::Token::Word") and $arg3->content eq "undef"
$arg3->isa("PPI::Token::Word") $arg3->content eq "undef"
Truth table66%2/3
A and B
A= $arg3->isa("PPI::Token::Word")B= $arg3->content eq "undef"
ABresult
0X0
100
111
865 3 return 1;
866 }
867 }
868 4 return '';
869 27 } );
870 }
871  
872 30 ▶sub _open_scalar {
Subroutine _open_scalar: called CC=1 SCAR=0.0
873 331 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=7 SCAR=19.5
874 331 ▶ $_[1]->isa('PPI::Statement') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement") or return "" 49 282 331
875 49 my @children = $_[1]->children;
876 #@children >= 7 or return '';
877 49 my $main_element = $children[0];
878 49 ▶ $main_element->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$main_element->isa("PPI::Token::Word") or return "" 29 20 49
879 29 ▶ $main_element->content eq 'open' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$main_element->content eq "open" or return "" 8 21 29
880 8 my @arguments = parse_arg_list($main_element);
881 8 ▶ if ( scalar @arguments == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @arguments == 3) 6 2 8
882 6 my $arg3 = $arguments[2][0];
883 6 ▶ if ($arg3->isa('PPI::Token::Cast') and $arg3->content eq '\\') {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg3->isa("PPI::Token::Cast") and $arg3->content eq "\\") 4 2 6
Condition66%2/3
$arg3->isa("PPI::Token::Cast") and $arg3->content eq "\\"
!ll&&!rl&&r
204
MC/DC50%1/2
$arg3->isa("PPI::Token::Cast") and $arg3->content eq "\\"
$arg3->isa("PPI::Token::Cast") $arg3->content eq "\\"
Truth table66%2/3
A and B
A= $arg3->isa("PPI::Token::Cast")B= $arg3->content eq "\\"
ABresult
0X0
100
111
884 4 return 1;
885 }
886 }
887 4 return '';
888 30 } );
889 }
890  
891 10 ▶sub _get_resulting_sigil {
Subroutine _get_resulting_sigil: called CC=3 SCAR=13.3
892 10 my $elem = shift;
893 10 ▶ if ($elem->isa('PPI::Token::Cast')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Cast')) { } 0 10 10
elsif ($elem->isa('PPI::Token::Symbol')) { } 10 0 10
894 0 return $elem->content;
895 } elsif ($elem->isa('PPI::Token::Symbol')) {
896 10 return $elem->symbol_type;
897 } else {
898 0 return undef;
899 }
900 }
901  
902 57 ▶sub _heredoc_indent {
Subroutine _heredoc_indent: called CC=1 SCAR=0.0
903 570 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
904 570 my $main_element = $_[1];
905 570 ▶ $main_element->isa('PPI::Token::HereDoc') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$main_element->isa("PPI::Token::HereDoc") or return "" 2 568 570
906 2 ▶ $main_element->content =~ /^\Q<<~\E/ or return '';
Branch: 1 branch
BranchTrueFalseTotal
$main_element->content =~ /^\<\<\~/ or return "" 1 1 2
907 1 return 1;
908 57 });
909 }
910  
911 # Postfix dereference new (and experimental) in 5.20, mainstream in 5.24.
912 # THIS CODE ASSUMES PPI 1.237_001 OR ABOVE -- i.e. support for postfix
913 # dereferencing.
914 #
915 21 my %postfix_deref = (
916 '$*' => \&_postfix_deref_entire,
917 '@*' => \&_postfix_deref_entire,
918 '$#*' => \&_postfix_deref_entire,
919 '%*' => \&_postfix_deref_entire,
920 '&*' => \&_postfix_deref_entire,
921 '**' => \&_postfix_deref_entire,
922 '@' => \&_postfix_deref_slice,
923 '%' => \&_postfix_deref_slice,
924 );
925  
926 4 ▶sub _postfix_deref_slice {
Subroutine _postfix_deref_slice: called CC=2 SCAR=7.1
927 4 my ( $elem ) = @_;
928 4 ▶ my $next = $elem->snext_sibling()
Branch: 1 branch
BranchTrueFalseTotal
my $next = $elem->snext_sibling or return 4 0 4
929 or return;
930 4 return $next->isa( 'PPI::Structure::Subscript' );
931 }
932  
933 6 ▶sub _postfix_deref_entire {
Subroutine _postfix_deref_entire: called CC=1 SCAR=0.0
934 6 return 1;
935 }
936  
937 54 ▶sub _postfix_deref {
Subroutine _postfix_deref: called CC=1 SCAR=0.2
938 509 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=11 SCAR=26.6
939 509 my $main_element=$_[1];
940 509 ▶ $main_element->isa('PPI::Token::Cast') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$main_element->isa("PPI::Token::Cast") or return "" 11 498 509
941 11 ▶ my $prev = $main_element->sprevious_sibling()
Branch: 1 branch
BranchTrueFalseTotal
my $prev = $main_element->sprevious_sibling or return "" 11 0 11
942 or return '';
943 11 ▶ return '' unless $prev->isa('PPI::Token::Operator') &&
Branch: 1 branch
BranchTrueFalseTotal
unless $prev->isa("PPI::Token::Operator") and $prev->content eq "->" 1 10 11
Condition66%2/3
$prev->isa("PPI::Token::Operator") and $prev->content eq "->"
!ll&&!rl&&r
1010
MC/DC50%1/2
$prev->isa("PPI::Token::Operator") and $prev->content eq "->"
$prev->isa("PPI::Token::Operator") $prev->content eq "->"
Truth table66%2/3
A and B
A= $prev->isa("PPI::Token::Operator")B= $prev->content eq "->"
ABresult
0X0
100
111
944 $prev->content() eq '->';
945 10 ▶ $prev = $prev->sprevious_sibling()
Branch: 1 branch
BranchTrueFalseTotal
$prev = $prev->sprevious_sibling or return "" 10 0 10
946 or return '';
947 10 ▶ return '' unless $prev->isa('PPI::Token::Symbol') &&
Branch: 1 branch
BranchTrueFalseTotal
unless $prev->isa("PPI::Token::Symbol") and (_get_resulting_sigil($prev) || "") eq "\$" 0 10 10
Condition40%2/5
$prev->isa("PPI::Token::Symbol") and (_get_resulting_sigil($prev) || "") eq "\$"
!ll&&!rl&&r
0010
_get_resulting_sigil($prev) || ''
l!l
100
MC/DC0%0/2
$prev->isa("PPI::Token::Symbol") and (_get_resulting_sigil($prev) || "") eq "\$"
$prev->isa("PPI::Token::Symbol") _get_resulting_sigil($prev)
Truth table33%1/3
A and B
A= $prev->isa("PPI::Token::Symbol")B= _get_resulting_sigil($prev)
ABresult
0X0
100
111
948 (_get_resulting_sigil($prev) || '') eq '$';
949 10 ▶ my $code = $postfix_deref{ $main_element->content() }
Branch: 1 branch
BranchTrueFalseTotal
my $code = $postfix_deref{$main_element->content} or return "" 10 0 10
950 or return '';
951 10 ▶ return $code->( $main_element ) || '';
Condition50%1/2
&$code($main_element) || ''
l!l
100
MC/DC0%0/1
&$code($main_element) || ''
&$code($main_element)
Truth table50%1/2
A
A= &$code($main_element)
Aresult
11
00
952 54 } );
953 }
954  
955 42 ▶sub _postfix_when {
Subroutine _postfix_when: called CC=1 SCAR=0.1
956 465 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=10 SCAR=23.8
957 465 my $main_element=$_[1];
958 465 ▶ $main_element->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$main_element->isa("PPI::Token::Word") or return "" 57 408 465
959 57 ▶ $main_element->content eq 'when' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$main_element->content eq "when" or return "" 5 52 57
960 5 ▶ return '' if is_hash_key($main_element);
Branch: 1 branch
BranchTrueFalseTotal
if is_hash_key($main_element) 0 5 5
961 5 ▶ return '' if is_method_call($main_element);
Branch: 1 branch
BranchTrueFalseTotal
if is_method_call($main_element) 0 5 5
962 5 ▶ return '' if is_subroutine_name($main_element);
Branch: 1 branch
BranchTrueFalseTotal
if is_subroutine_name($main_element) 0 5 5
963 5 ▶ return '' if is_included_module_name($main_element);
Branch: 1 branch
BranchTrueFalseTotal
if is_included_module_name($main_element) 0 5 5
964 5 ▶ return '' if is_package_declaration($main_element);
Branch: 1 branch
BranchTrueFalseTotal
if is_package_declaration($main_element) 0 5 5
965 5 my $stmnt = $main_element->statement();
966 5 ▶ return '' if !$stmnt;
Branch: 1 branch
BranchTrueFalseTotal
unless $stmnt 0 5 5
967 5 ▶ return '' if $stmnt->isa('PPI::Statement::When');
Branch: 1 branch
BranchTrueFalseTotal
if $stmnt->isa("PPI::Statement::When") 2 3 5
968 3 return 1;
969 42 } );
970 }
971  
972 46 ▶sub _yada_yada_yada {
Subroutine _yada_yada_yada: called CC=1 SCAR=0.0
973 469 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
974 469 ▶ $_[1]->isa('PPI::Token::Operator')
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Operator") and $_[1]->content eq "..." or return "" 8 461 469
Condition100%3/3
$_[1]->isa("PPI::Token::Operator") and $_[1]->content eq "..."
!ll&&!rl&&r
435268
MC/DC100%2/2
$_[1]->isa("PPI::Token::Operator") and $_[1]->content eq "..."
$_[1]->isa("PPI::Token::Operator") $_[1]->content eq "..."
Truth table100%3/3
A and B
A= $_[1]->isa("PPI::Token::Operator")B= $_[1]->content eq "..."
ABresult
0X0
100
111
975 and $_[1]->content eq '...' or return '';
976 8 my @child = $_[1]->parent->schildren;
977 8 ▶ @child == 1 and return 1;
Branch: 1 branch
BranchTrueFalseTotal
@child == 1 and return 1 5 3 8
978 3 ▶ if (@child == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@child == 2) 1 2 3
979 1 $child[1]->isa('PPI::Token::Structure')
980 }
981 46 } );
982 }
983  
984 31 ▶sub _state_declaration {
Subroutine _state_declaration: called CC=1 SCAR=0.0
985 300 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=3 SCAR=11.1
986 300 ▶ $_[1]->isa('PPI::Statement::Variable')
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Variable") and ($_[1]->children)[0]->isa("PPI::Token::Word") and ($_[1]->children)[0]->content eq "state" 7 293 300
Condition66%2/3
$_[1]->isa("PPI::Statement::Variable") and ($_[1]->children)[0]->isa("PPI::Token::Word")
!ll&&!rl&&r
29307
MC/DC50%1/2
$_[1]->isa("PPI::Statement::Variable") and ($_[1]->children)[0]->isa("PPI::Token::Word")
$_[1]->isa("PPI::Statement::Variable") ($_[1]->children)[0]->isa("PPI::Token::Word")
Truth table66%2/3
A and B
A= $_[1]->isa("PPI::Statement::Variable")B= ($_[1]->children)[0]->isa("PPI::Token::Word")
ABresult
0X0
100
111
987 and ($_[1]->children)[0]->isa('PPI::Token::Word')
988 and ($_[1]->children)[0]->content eq 'state'
989 31 } );
990 }
991  
992 0 ▶sub _stacked_labels {
Subroutine _stacked_labels: not called CC=1 SCAR=6.9
993 0 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
994 0 ▶ $_[1]->isa('PPI::Statement::Compound') || return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Compound") or return "" 0 0 0
995 0 ▶ $_[1]->schild(0)->isa('PPI::Token::Label') || return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->schild(0)->isa("PPI::Token::Label") or return "" 0 0 0
996  
997 0 ▶ my $next = $_[1]->snext_sibling || return '';
Condition0%0/2
$_[1]->snext_sibling || (return '')
l!l
00
MC/DC0%0/1
$_[1]->snext_sibling || (return '')
$_[1]->snext_sibling
Truth table0%0/2
A
A= $_[1]->snext_sibling
Aresult
11
00
998  
999 0 ▶ if ( $next->isa('PPI::Statement::Compound')
Branch: 1 branch
BranchTrueFalseTotal
if ($next->isa("PPI::Statement::Compound") and $next->schild(0)->isa("PPI::Token::Label")) 0 0 0
Condition0%0/3
$next->isa("PPI::Statement::Compound") and $next->schild(0)->isa("PPI::Token::Label")
!ll&&!rl&&r
000
MC/DC0%0/2
$next->isa("PPI::Statement::Compound") and $next->schild(0)->isa("PPI::Token::Label")
$next->isa("PPI::Statement::Compound") $next->schild(0)->isa("PPI::Token::Label")
Truth table0%0/3
A and B
A= $next->isa("PPI::Statement::Compound")B= $next->schild(0)->isa("PPI::Token::Label")
ABresult
0X0
100
111
1000 && $next->schild(0)->isa('PPI::Token::Label')) {
1001 0 return 1;
1002 }
1003  
1004 0 0;
1005 0 } );
1006 }
1007  
1008 26 ▶sub _internals_svreadonly {
Subroutine _internals_svreadonly: called CC=1 SCAR=0.0
1009 260 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1010 260 ▶ $_[1]->isa('PPI::Statement')
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement") and ($_[1]->children)[0]->isa("PPI::Token::Word") and ($_[1]->children)[0]->content eq "Internals::SvREADONLY" 23 237 260
Condition100%3/3
$_[1]->isa("PPI::Statement") and ($_[1]->children)[0]->isa("PPI::Token::Word")
!ll&&!rl&&r
2181923
MC/DC100%2/2
$_[1]->isa("PPI::Statement") and ($_[1]->children)[0]->isa("PPI::Token::Word")
$_[1]->isa("PPI::Statement") ($_[1]->children)[0]->isa("PPI::Token::Word")
Truth table100%3/3
A and B
A= $_[1]->isa("PPI::Statement")B= ($_[1]->children)[0]->isa("PPI::Token::Word")
ABresult
0X0
100
111
1011 and ($_[1]->children)[0]->isa('PPI::Token::Word')
1012 and ($_[1]->children)[0]->content eq 'Internals::SvREADONLY'
1013 26 } );
1014 }
1015  
1016 46 ▶sub _pkg_name_version {
Subroutine _pkg_name_version: called CC=1 SCAR=0.0
1017 420 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=6 SCAR=18.2
1018 420 ▶ $_[1]->isa('PPI::Statement::Package') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Package") or return "" 9 411 420
1019 9 my @child = $_[1]->schildren();
1020 9 ▶ $child[0]->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$child[0]->isa("PPI::Token::Word") or return "" 9 0 9
1021 9 ▶ $child[0]->content eq 'package' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$child[0]->content eq "package" or return "" 9 0 9
1022 9 ▶ $child[1]->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$child[1]->isa("PPI::Token::Word") or return "" 9 0 9
1023 9 ▶ $child[2]->isa('PPI::Token::Number') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$child[2]->isa("PPI::Token::Number") or return "" 6 3 9
1024 6 return 1;
1025 46 } );
1026 }
1027  
1028 33 ▶sub _perl_5010_pragmas {
Subroutine _perl_5010_pragmas: called CC=1 SCAR=0.0
1029 275 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1030 $_[1]->isa('PPI::Statement::Include')
1031 and
1032 275 ▶ $MATCHES{_perl_5010_pragmas}->{$_[1]->pragma}
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Include") and $MATCHES{"_perl_5010_pragmas"}{$_[1]->pragma} 12 263 275
1033 33 } );
1034 }
1035  
1036 34 ▶sub _perl_5010_operators {
Subroutine _perl_5010_operators: called CC=1 SCAR=0.0
1037 364 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1038 $_[1]->isa('PPI::Token::Operator')
1039 and
1040 364 ▶ $MATCHES{_perl_5010_operators}->{$_[1]->content}
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Operator") and $MATCHES{"_perl_5010_operators"}{$_[1]->content} 23 341 364
1041 34 } );
1042 }
1043  
1044 33 ▶sub _perl_5010_magic {
Subroutine _perl_5010_magic: called CC=1 SCAR=0.0
1045 339 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1046 $_[1]->isa('PPI::Token::Magic')
1047 and
1048 339 ▶ $MATCHES{_perl_5010_magic}->{$_[1]->symbol}
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Magic") and $MATCHES{"_perl_5010_magic"}{$_[1]->symbol} 4 335 339
1049 33 } );
1050 }
1051  
1052 22 ▶sub _perl_5008_pragmas {
Subroutine _perl_5008_pragmas: called CC=1 SCAR=0.0
1053 186 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1054 $_[1]->isa('PPI::Statement::Include')
1055 and
1056 186 ▶ $MATCHES{_perl_5008_pragmas}->{$_[1]->pragma}
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Include") and $MATCHES{"_perl_5008_pragmas"}{$_[1]->pragma} 10 176 186
1057 22 } );
1058 }
1059  
1060 # 5.8.3: Reading $^E now preserves $!. Previously, the C code implementing $^E did not preserve errno, so reading $^E could cause errno and therefore $! to change unexpectedly.
1061 26 ▶sub _bugfix_magic_errno {
Subroutine _bugfix_magic_errno: called CC=3 SCAR=11.0
1062 26 my $Document = shift->Document;
1063 291 ▶ my $element = $Document->find_first( sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1064 291 ▶ $_[1]->isa('PPI::Token::Magic')
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Magic") and $_[1]->symbol eq "\$^E" 4 287 291
1065 and
1066 $_[1]->symbol eq '$^E'
1067 26 ▶ } ) || return undef;
Condition100%2/2
$Document->find_first(sub { $_[1]->isa('PPI::Token::Magic') and $_[1]->symbol eq '$^E'; } ) || (return undef)
l!l
224
MC/DC100%1/1
$Document->find_first(sub { $_[1]->isa('PPI::Token::Magic') and $_[1]->symbol eq '$^E'; } ) || (return undef)
$Document->find_first(sub { $_[1]->isa('PPI::Token::Magic') and $_[1]->symbol eq '$^E'; } )
Truth table100%2/2
A
A= $Document->find_first(sub { $_[1]->isa('PPI::Token::Magic') and $_[1]->symbol eq '$^E'; } )
Aresult
11
00
1068 #$^E is more rare than $!, so search for it first and return it
1069 4 ▶ $Document->find_any( sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
1070 4 ▶ $_[1]->isa('PPI::Token::Magic')
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Magic") and $_[1]->symbol eq "\$!" 2 2 4
1071 and
1072 $_[1]->symbol eq '$!'
1073 2 ▶ } ) || return '';
Branch: 1 branch
BranchTrueFalseTotal
$Document->find_any(sub { $_[1]->isa("PPI::Token::Magic") and $_[1]->symbol eq "\$!"; } ) or return "" 2 0 2
1074 2 return $element;
1075 }
1076  
1077 # utf8::is_utf requires 5.8.1 unlike the rest of utf8
1078 24 ▶sub _is_utf8 {
Subroutine _is_utf8: called CC=1 SCAR=0.2
1079 279 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=3 SCAR=11.7
1080 279 ▶ $_[1]->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Word") or return "" 31 248 279
1081 31 ▶ $_[1] eq 'utf8::is_utf' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1] eq "utf8::is_utf" or return "" 0 31 31
1082 0 return 1;
1083 24 } );
1084 }
1085  
1086 # version->new(5.005.004);
1087 24 ▶sub _unquoted_versions {
Subroutine _unquoted_versions: called CC=1 SCAR=5.2
1088 279 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=17 SCAR=54.2
1089 279 ▶ $_[1]->isa('PPI::Token::Number') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Number") or return "" 17 262 279
1090 17 ▶ $_[1]->{_subtype} or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]{"_subtype"} or return "" 0 17 17
1091 0 ▶ $_[1]->{_subtype} eq 'base256' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]{"_subtype"} eq "base256" or return "" 0 0 0
1092 0 ▶ my $stmt = $_[1]->parent or return '';
Branch: 1 branch
BranchTrueFalseTotal
my $stmt = $_[1]->parent or return "" 0 0 0
1093 0 ▶ my $braces = $stmt->parent or return '';
Branch: 1 branch
BranchTrueFalseTotal
my $braces = $stmt->parent or return "" 0 0 0
1094 0 ▶ $braces->isa('PPI::Structure') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$braces->isa("PPI::Structure") or return "" 0 0 0
1095 0 ▶ $braces->braces eq '()' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$braces->braces eq "()" or return "" 0 0 0
1096 0 ▶ my $new = $braces->previous_sibling or return '';
Branch: 1 branch
BranchTrueFalseTotal
my $new = $braces->previous_sibling or return "" 0 0 0
1097 0 ▶ $new->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$new->isa("PPI::Token::Word") or return "" 0 0 0
1098 0 ▶ $new->content eq 'new' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$new->content eq "new" or return "" 0 0 0
1099 0 ▶ my $method = $new->previous_sibling or return '';
Branch: 1 branch
BranchTrueFalseTotal
my $method = $new->previous_sibling or return "" 0 0 0
1100 0 ▶ $method->isa('PPI::Token::Operator') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$method->isa("PPI::Token::Operator") or return "" 0 0 0
1101 0 ▶ $method->content eq '->' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$method->content eq "->" or return "" 0 0 0
1102 0 ▶ my $_class = $method->previous_sibling or return '';
Branch: 1 branch
BranchTrueFalseTotal
my $_class = $method->previous_sibling or return "" 0 0 0
1103 0 ▶ $_class->isa('PPI::Token::Word') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_class->isa("PPI::Token::Word") or return "" 0 0 0
1104 0 ▶ $_class->content eq 'version' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_class->content eq "version" or return "" 0 0 0
1105 0 1;
1106 24 } );
1107 }
1108  
1109 21 ▶sub _pragma_utf8 {
Subroutine _pragma_utf8: called CC=1 SCAR=0.0
1110 217 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=5 SCAR=16.2
1111 217 ▶ $_[1]->isa('PPI::Statement::Include')
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Include") and $_[1]->module && $_[1]->module eq "utf8" || $_[1]->pragma && $_[1]->pragma eq "utf8" 9 208 217
Condition83%10/12
$_[1]->isa('PPI::Statement::Include') && ($_[1]->module && $_[1]->module eq 'utf8' || $_[1]->pragma && $_[1]->pragma eq 'utf8')
!ll&&!rl&&r
20881
$_[1]->module and $_[1]->module eq "utf8" or $_[1]->pragma and $_[1]->pragma eq "utf8"
l!l&&r!l&&!r
108
$_[1]->module and $_[1]->module eq "utf8"
!ll&&!rl&&r
351
$_[1]->pragma and $_[1]->pragma eq "utf8"
!ll&&!rl&&r
350
MC/DC60%3/5
$_[1]->isa('PPI::Statement::Include') && ($_[1]->module && $_[1]->module eq 'utf8' || $_[1]->pragma && $_[1]->pragma eq 'utf8')
$_[1]->isa('PPI::Statement::Include') $_[1]->module $_[1]->module eq "utf8" $_[1]->pragma $_[1]->pragma eq "utf8"
Truth table50%4/8
A && B and C or D and E
A= $_[1]->isa('PPI::Statement::Include')B= $_[1]->moduleC= $_[1]->module eq "utf8"D= $_[1]->pragmaE= $_[1]->pragma eq "utf8"
ABCDEresult
0XXXX0
10X0X0
10X100
1100X0
110100
111XX1
10X111
110111
1112 and
1113 (
1114 ($_[1]->module and $_[1]->module eq 'utf8')
1115 or
1116 ($_[1]->pragma and $_[1]->pragma eq 'utf8')
1117 )
1118 # This used to be just pragma(), but that was buggy in PPI v1.118
1119 21 } );
1120 }
1121  
1122 # Check for the use of 'use constant { ... }'
1123 22 ▶sub _constant_hash {
Subroutine _constant_hash: called CC=1 SCAR=0.0
1124 227 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
1125 227 ▶ $_[1]->isa('PPI::Statement::Include')
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Include") and $_[1]->type and $_[1]->type eq "use" and $_[1]->module eq "constant" and $_[1]->schild(2)->isa("PPI::Structure") 2 225 227
Condition88%8/9
$_[1]->isa("PPI::Statement::Include") and $_[1]->type and $_[1]->type eq "use" and $_[1]->module eq "constant"
!ll&&!rl&&r
21872
$_[1]->isa("PPI::Statement::Include") and $_[1]->type and $_[1]->type eq "use"
!ll&&!rl&&r
21719
$_[1]->isa("PPI::Statement::Include") and $_[1]->type
!ll&&!rl&&r
217010
MC/DC75%3/4
$_[1]->isa("PPI::Statement::Include") and $_[1]->type and $_[1]->type eq "use" and $_[1]->module eq "constant"
$_[1]->isa("PPI::Statement::Include") $_[1]->type $_[1]->type eq "use" $_[1]->module eq "constant"
Truth table80%4/5
A and B and C and D
A= $_[1]->isa("PPI::Statement::Include")B= $_[1]->typeC= $_[1]->type eq "use"D= $_[1]->module eq "constant"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1126 and
1127 $_[1]->type
1128 and
1129 $_[1]->type eq 'use'
1130 and
1131 $_[1]->module eq 'constant'
1132 and
1133 $_[1]->schild(2)->isa('PPI::Structure')
1134 22 } );
1135 }
1136  
1137 # You can't localize a soft reference
1138 24 ▶sub _local_soft_reference {
Subroutine _local_soft_reference: called CC=1 SCAR=0.1
1139 252 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=11 SCAR=25.6
1140 252 ▶ $_[1]->isa('PPI::Statement::Variable') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Variable") or return "" 3 249 252
1141 3 ▶ $_[1]->type eq 'local' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->type eq "local" or return "" 2 1 3
1142  
1143 # The second child should be a '$' cast.
1144 2 my @child = $_[1]->schildren;
1145 2 ▶ scalar(@child) >= 2 or return '';
Branch: 1 branch
BranchTrueFalseTotal
scalar @child >= 2 or return "" 2 0 2
1146 2 ▶ $child[1]->isa('PPI::Token::Cast') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$child[1]->isa("PPI::Token::Cast") or return "" 2 0 2
1147 2 ▶ $child[1]->content eq '$' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$child[1]->content eq "\$" or return "" 2 0 2
1148  
1149 # The third child should be a block
1150 2 ▶ $child[2]->isa('PPI::Structure::Block') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$child[2]->isa("PPI::Structure::Block") or return "" 2 0 2
1151  
1152 # Inside the block should be a string in a statement
1153 2 ▶ my $statement = $child[2]->schild(0) or return '';
Branch: 1 branch
BranchTrueFalseTotal
my $statement = $child[2]->schild(0) or return "" 2 0 2
1154 2 ▶ $statement->isa('PPI::Statement') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$statement->isa("PPI::Statement") or return "" 2 0 2
1155 2 ▶ my $inside = $statement->schild(0) or return '';
Branch: 1 branch
BranchTrueFalseTotal
my $inside = $statement->schild(0) or return "" 2 0 2
1156 2 ▶ $inside->isa('PPI::Token::Quote') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$inside->isa("PPI::Token::Quote") or return "" 2 0 2
1157  
1158 # This is indeed a localized soft reference
1159 2 return 1;
1160 24 } );
1161 }
1162  
1163 # Carp.pm did not have a $VERSION in 5.6.2
1164 # Therefore, even "use Carp 0" imposes a 5.8.0 dependency.
1165 20 ▶sub _use_carp_version {
Subroutine _use_carp_version: called CC=1 SCAR=1.2
1166 216 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=4 SCAR=18.9
1167 216 ▶ $_[1]->isa('PPI::Statement::Include') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Include") or return "" 8 208 216
1168 8 ▶ $_[1]->module eq 'Carp' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->module eq "Carp" or return "" 0 8 8
1169  
1170 0 my $version = $_[1]->module_version;
1171 0 ▶ return !! ( defined $version and length "$version" );
Condition0%0/3
defined $version && length "$version"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $version && length "$version"
defined $version length "$version"
Truth table0%0/3
A && B
A= defined $versionB= length "$version"
ABresult
0X0
100
111
1172 20 } );
1173 }
1174  
1175 # Double-diamond operator.
1176 # Detecting this requires at least PPI 1.252
1177 59 ▶sub _double_diamond_operator {
Subroutine _double_diamond_operator: called CC=1 SCAR=0.0
1178 561 ▶ shift->Document->find_first( sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1179 561 ▶ $_[1]->isa('PPI::Token::QuoteLike::Readline') or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::QuoteLike::Readline") or return "" 2 559 561
1180 2 ▶ $_[1]->content eq '<<>>' or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->content eq "<<>>" or return "" 1 1 2
1181 1 return 1;
1182 59 } );
1183 }
1184  
1185 #####################################################################
1186 # Support Functions
1187  
1188 # Let sub be a function, object method, and static method
1189 298 ▶sub _SELF {
Subroutine _SELF: called CC=4 SCAR=14.6
1190 298 my $param = shift;
1191 298 ▶ if ( _INSTANCE($param->[0], 'Perl::MinimumVersion') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&_INSTANCE($param->[0], "Perl::MinimumVersion")) 296 2 298
1192 296 return shift @$param;
1193 }
1194 2 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (&_CLASS($param->[0]) and $param->[0]->isa("Perl::MinimumVersion")) 2 0 2
Condition33%1/3
&_CLASS($param->[0]) and $param->[0]->isa("Perl::MinimumVersion")
!ll&&!rl&&r
002
MC/DC0%0/2
&_CLASS($param->[0]) and $param->[0]->isa("Perl::MinimumVersion")
&_CLASS($param->[0]) $param->[0]->isa("Perl::MinimumVersion")
Truth table33%1/3
A and B
A= &_CLASS($param->[0])B= $param->[0]->isa("Perl::MinimumVersion")
ABresult
0X0
100
111
1195 _CLASS($param->[0])
1196 and
1197 $param->[0]->isa('Perl::MinimumVersion')
1198 ) {
1199 2 my $class = shift @$param;
1200 2 my $options = shift @$param;
1201 2 return $class->new($options);
1202 }
1203 0 Perl::MinimumVersion->new(shift @$param);
1204 }
1205  
1206 # Find the maximum version, ignoring problems
1207 18 ▶sub _max {
Subroutine _max: called CC=8 SCAR=20.9
1208 18 ▶ defined $_[0] and "$_[0]" eq PMV and shift;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] and "$_[0]" eq "Perl::MinimumVersion" and shift() 9 9 18
Condition100%3/3
defined $_[0] and "$_[0]" eq "Perl::MinimumVersion"
!ll&&!rl&&r
279
MC/DC100%2/2
defined $_[0] and "$_[0]" eq "Perl::MinimumVersion"
defined $_[0] "$_[0]" eq "Perl::MinimumVersion"
Truth table100%3/3
A and B
A= defined $_[0]B= "$_[0]" eq "Perl::MinimumVersion"
ABresult
0X0
100
111
1209  
1210 # Filter and prepare for a Schwartian maximum
1211 my @valid = map {
1212 26 ▶ [ $_, $_->isa('Perl::MinimumVersion::Reason') ? $_->version : $_ ]
Branch: 1 branch
BranchTrueFalseTotal
$_->isa('Perl::MinimumVersion::Reason') ? : 0 26 26
1213 } grep {
1214 18 ▶ _INSTANCE($_, 'Perl::MinimumVersion::Reason')
Branch: 1 branch
BranchTrueFalseTotal
my(@valid) = map({[$_, $_->isa("Perl::MinimumVersion::Reason") ? $_->version : $_];} grep({&_INSTANCE($_, "Perl::MinimumVersion::Reason") or &_INSTANCE($_, "version");} @_)) or return "" 12 6 18
Condition66%2/3
&_INSTANCE($_, 'Perl::MinimumVersion::Reason') || &_INSTANCE($_, 'version')
l!l&&r!l&&!r
02610
MC/DC50%1/2
&_INSTANCE($_, 'Perl::MinimumVersion::Reason') || &_INSTANCE($_, 'version')
&_INSTANCE($_, 'Perl::MinimumVersion::Reason') &_INSTANCE($_, 'version')
Truth table66%2/3
A || B
A= &_INSTANCE($_, 'Perl::MinimumVersion::Reason')B= &_INSTANCE($_, 'version')
ABresult
1X1
011
000
1215 or
1216 _INSTANCE($_, 'version')
1217 } @_ or return '';
1218  
1219 # Find the maximum
1220 12 my $max = shift @valid;
1221 12 foreach my $it ( @valid ) {
1222 14 ▶ $max = $it if $it->[1] > $max->[1];
Branch: 1 branch
BranchTrueFalseTotal
if $it->[1] > $max->[1] 4 10 14
1223 }
1224  
1225 12 return $max->[0];
1226 }
1227  
1228 21 1;
1229  
1230 =pod
1231  
1232 =head1 BUGS
1233  
1234 B<Perl::MinimumVersion> does a reasonable job of catching the best-known
1235 explicit version dependencies.
1236  
1237 B<However> it is exceedingly easy to add a new syntax check, so if you
1238 find something this is missing, copy and paste one of the existing
1239 5 line checking functions, modify it to find what you want, and report it
1240 to rt.cpan.org, along with the version needed.
1241  
1242 I don't even need an entire diff... just the function and version.
1243  
1244 =head1 TO DO
1245  
1246 B<Write lots more version checkers>
1247  
1248 - Perl 5.10 operators and language structures
1249  
1250 - Three-argument open
1251  
1252 B<Write the explicit version checker>
1253  
1254 B<Write the recursive module descend stuff>
1255  
1256 _while_readdir for postfix while without brackets
1257  
1258 B<Check for more 5.12 features (currently only detecting
1259 C<package NAME VERSION;>, C<...>, and C<use feature ':5.12'>)>
1260  
1261 =head1 SUPPORT
1262  
1263 All bugs should be filed via the CPAN bug tracker at
1264  
1265 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Perl-MinimumVersion>
1266  
1267 For other issues, or commercial enhancement or support, contact the author.
1268  
1269 =head1 AUTHORS
1270  
1271 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
1272  
1273 =head1 SEE ALSO
1274  
1275 L<perlver> - the command-line script for running C<Perl::MinimumVersion>
1276 on your code.
1277  
1278 L<Perl::MinimumVersion::Fast> - another module which does the same thing.
1279 It's a lot faster, but only supports Perl 5.8.1+.
1280  
1281 L<http://ali.as/>, L<PPI>, L<version>
1282  
1283 =head1 REPOSITORY
1284  
1285 L<https://github.com/neilbowers/Perl-MinimumVersion>
1286  
1287 =head1 COPYRIGHT
1288  
1289 Copyright 2005 - 2014 Adam Kennedy.
1290  
1291 This program is free software; you can redistribute
1292 it and/or modify it under the same terms as Perl itself.
1293  
1294 The full text of the license can be found in the
1295 LICENSE file included with this module.
1296  
1297 =cut
↑ Summary MinimumVersion/Reason.pm »