lib/Pod/Coverage/More/Analyzer.pm

filter: Statementstmt 94.9% 637 / 671 Branchbran 78.6% 327 / 416 Conditioncond 65.4% 186 / 284 MC/DCmcdc 39.3% 63 / 160 Subroutinesub 95.0% 77 / 81 Podpod 100% 9 / 9 totaltotal 80.1% 1299 / 1621 CC 331 SCAR 27.0
CC
331
Cov
84%
_classify_refgen
72.0
classify
41.4
_last_values
39.2
CRAP 14.8
« lib/Pod/Coverage/More/Analyzer/Perl5_36.pm ↑ Summary lib/Pod/Coverage/More/Types.pm »
1 # ABSTRACT: Infer arguments, return values and termination of subs from their compiled op trees
2 # PODNAME: Pod::Coverage::More::Analyzer
3  
4 package Pod::Coverage::More::Analyzer 0.003;
5  
6 19 ▶use 5.036;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 19 ▶use warnings FATAL => q{all};
Subroutine BEGIN: called CC=1 SCAR=0.0
8 19 ▶use re q{/xsaa};
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 19 ▶use B ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 19 ▶use List::Util qw{any};
Subroutine BEGIN: called CC=1 SCAR=0.0
12 19 ▶use Module::Runtime qw{require_module module_notional_filename};
Subroutine BEGIN: called CC=1 SCAR=0.0
13 19 ▶use Package::Stash;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 19 ▶use Pod::Coverage::More::Declared;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 19 ▶use Pod::Coverage::More::Types qw{type_of_value type_of_usage type_named};
Subroutine BEGIN: called CC=1 SCAR=0.0
17 19 ▶use Scalar::Util qw{blessed};
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 # The pad and SV helpers return an explicit undef because their callers put them in hash constructors,
20 # where a bare return would give an empty list and shift every pair after it.
21  
22  
23 # Lowest perl version of each version set, highest first.
24 19 our @BACKENDS = (
25 [ 5.044 => 'Pod::Coverage::More::Analyzer::Perl5_44' ],
26 [ 5.038 => 'Pod::Coverage::More::Analyzer::Perl5_38' ],
27 [ 5.036 => 'Pod::Coverage::More::Analyzer::Perl5_36' ],
28 );
29  
30 # The ops whose names say what kind of value they read or produce.
31 19 our %NUMERIC_OPS = map { $_ => 1 } qw{
32 add subtract multiply divide modulo pow negate abs int sqrt
33 lt gt le ge eq ne ncmp preinc predec postinc postdec
34 i_add i_subtract i_multiply i_divide i_modulo i_negate
35 i_lt i_gt i_le i_ge i_eq i_ne i_ncmp i_preinc i_predec i_postinc i_postdec
36 };
37 19 our %STRING_OPS = map { $_ => 1 } qw{
38 concat multiconcat seq sne slt sgt sle sge scmp
39 lc uc lcfirst ucfirst length substr index rindex match subst split
40 };
41 19 our %TERMINATORS = map { $_ => 1 } qw{
42 CORE::GLOBAL::die CORE::GLOBAL::exit
43 Carp::croak Carp::confess
44 POSIX::_exit
45 };
46  
47 # Methods that die by their contract: an exception class's throw, and the fatal level of a logger, as
48 # Log::Dispatchouli and so Dist::Zilla's log_fatal, and Log::Log4perl's logdie, logcroak and logconfess.
49 19 our %TERMINATING_METHODS = map { $_ => 1 } qw{throw log_fatal logdie logcroak logconfess};
50 19 our %BOOLEAN_OPS = map { $_ => 1 } qw{
51 not defined exists
52 lt gt le ge eq ne i_lt i_gt i_le i_ge i_eq i_ne
53 slt sgt sle sge seq sne
54 };
55  
56 # The ops whose result is always a whole number.
57 19 our %INTEGER_OPS = map { $_ => 1 } qw{
58 index rindex scmp time
59 i_add i_subtract i_multiply i_divide i_modulo i_negate i_ncmp
60 };
61  
62 # The ops whose result is a whole number or undef: length of undef, and <=> of NaN.
63 19 our %MAYBE_INTEGER_OPS = map { $_ => 1 } qw{length ncmp};
64  
65 # The classes that the numbers of the scope of each bignum pragma are, by its key in %^H.
66 19 our %BIG_CLASSES = (
67 bigint => ['Math::BigInt'],
68 bignum => [ 'Math::BigInt', 'Math::BigFloat' ],
69 bigrat => ['Math::BigRat'],
70 bigfloat => ['Math::BigFloat'],
71 );
72 19 our %NUMBER_OPS = map { $_ => 1 } qw{
73 add subtract multiply divide modulo pow negate abs int sqrt ncmp scmp
74 i_add i_subtract i_multiply i_divide i_modulo i_negate i_ncmp
75 length index rindex time
76 };
77 19 our %STRING_RESULT_OPS = map { $_ => 1 } qw{
78 concat multiconcat stringify join sprintf lc uc lcfirst ucfirst substr ref
79 };
80 19 our %LIST_OPS = map { $_ => 1 } qw{ sort grepwhile mapwhile keys values reverse split };
81 19 our $HELEM = B::opnumber(q{helem});
82 19 our @HASH_MDEREF_ACTIONS = (
83 B::MDEREF_HV_pop_rv2hv_helem(), B::MDEREF_HV_gvsv_vivify_rv2hv_helem(),
84 B::MDEREF_HV_padsv_vivify_rv2hv_helem(), B::MDEREF_HV_vivify_rv2hv_helem(),
85 B::MDEREF_HV_padhv_helem(), B::MDEREF_HV_gvhv_helem(),
86 );
87  
88  
89 # An analyzer of the subclass that handles the running perl.
90 # @returns Object the analyzer, an instance of that subclass
91 # @throws when the running perl is older than the oldest supported version set
92 # @example my $analyzer = Pod::Coverage::More::Analyzer->new;
93 26 ▶sub new {
Subroutine new: called CC=3 SCAR=11.4
Pod documented
94 26 my ($class) = @_;
95 26 ▶ my $backend = $class eq __PACKAGE__ ? backend_for($]) : $class;
Branch: 1 branch
BranchTrueFalseTotal
$class eq __PACKAGE__ ? : 26 0 26
96 26 ▶ require_module($backend) if $backend ne $class;
Branch: 1 branch
BranchTrueFalseTotal
if $backend ne $class 26 0 26
97 26 return bless( {}, $backend );
98 }
99  
100 # The subclass that handles the perl C<version>.
101 # @param version Num in the numeric form of C<$]>
102 # @returns Str the name of the subclass
103 # @throws when no subclass handles the version
104 # @example my $backend = Pod::Coverage::More::Analyzer::backend_for($]);
105 35 ▶sub backend_for {
Subroutine backend_for: called CC=3 SCAR=11.0
Pod documented
106 35 my ($version) = @_;
107 35 foreach my $backend (@BACKENDS) {
108 45 ▶ return $backend->[1] if $version >= $backend->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $version >= $backend->[0] 33 12 45
109 }
110 2 die "Perl $version is not supported, the oldest supported perl is $BACKENDS[-1][0]\n";
111 }
112  
113 # The records of the subs that C<package> defines, as C<analyze_sub> returns them.
114 # The package must be loaded already. Subs that it imported from another package are left out.
115 #
116 # When a class builder or a signature module declares a sub, as L<Pod::Coverage::More::Declared> reads it,
117 # its record also has C<declared>: that declaration, with C<wrapped> in place of its C<body>,
118 # and each parameter that a declared one matches has C<declared>, the declared L<Type::Tiny> constraint.
119 # The record of a sub that only wraps the code that does the work describes that code.
120 # @param package Str the name of the package
121 # @returns HashRef from the name of each sub to its record
122 # @example my $records = $analyzer->analyze_package('Pod::Coverage::More');
123 42 ▶sub analyze_package {
Subroutine analyze_package: called CC=7 SCAR=19.5
Pod documented
124 42 my ( $self, $package ) = @_;
125  
126 42 my $stash = Package::Stash->new($package);
127 42 my %code;
128 42 foreach my $name ( $stash->list_all_symbols(q{CODE}) ) {
129 426 my $code = $stash->get_symbol("&$name");
130 426 ▶ $code{$name} = $code if _defined_in( B::svref_2object($code) ) eq $package;
Branch: 1 branch
BranchTrueFalseTotal
if _defined_in(B::svref_2object($code)) eq $package 359 67 426
131 }
132  
133 42 my $declared = Pod::Coverage::More::Declared->declarations_for( $package, [ sort keys %code ] );
134 42 my %subs;
135 42 foreach my $name ( sort keys %code ) {
136 359 my $declaration = $declared->{$name};
137 359 ▶ my $body = $declaration ? $declaration->{body} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$declaration ? : 23 336 359
138 359 ▶ $subs{$name} = $self->analyze_sub( $body // $code{$name}, $name, $package );
Condition66%2/3
$body // $code{$name}
l!l&&r!l&&!r
33560
MC/DC0%0/2
$body // $code{$name}
$body $code{$name}
Truth table66%2/3
A // B
A= $bodyB= $code{$name}
ABresult
1X1
011
000
139 359 ▶ _attach_declaration( $subs{$name}, $declaration ) if $declaration;
Branch: 1 branch
BranchTrueFalseTotal
if $declaration 23 336 359
140 }
141 42 return \%subs;
142 }
143  
144 # Records DECLARATION on the record REC, and the declared type of each parameter on the parameter that it matches:
145 # by name, or else by position. The invocant is never matched, because a class builder and the code number it differently.
146 23 ▶sub _attach_declaration {
Subroutine _attach_declaration: called CC=12 SCAR=24.9
147 23 my ( $rec, $declaration ) = @_;
148 23 my %declared = %$declaration;
149 23 ▶ $declared{wrapped} = delete( $declared{body} ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
delete $declared{'body'} ? : 3 20 23
150 23 $rec->{declared} = \%declared;
151  
152 23 foreach my $param ( @{ $rec->{params} } ) {
153 20 foreach my $candidate ( @{ $declaration->{params} } ) {
154 37 ▶ next if $candidate->{invocant} || !$candidate->{type};
Branch: 1 branch
BranchTrueFalseTotal
if $candidate->{"invocant"} or not $candidate->{"type"} 16 21 37
Condition100%3/3
$candidate->{"invocant"} or not $candidate->{"type"}
l!l&&r!l&&!r
12421
MC/DC100%2/2
$candidate->{"invocant"} or not $candidate->{"type"}
$candidate->{"invocant"} not $candidate->{"type"}
Truth table100%3/3
A or not(B)
A= $candidate->{"invocant"}B= not $candidate->{"type"}
ABresult
1X1
011
000
155 21 ▶ my $by_name = defined $candidate->{name} && defined $param->{name} && $candidate->{name} eq $param->{name};
Condition83%5/6
defined $candidate->{'name'} && defined $param->{'name'} && $candidate->{'name'} eq $param->{'name'}
!ll&&!rl&&r
1344
defined $candidate->{"name"} and defined $param->{"name"}
!ll&&!rl&&r
1308
MC/DC66%2/3
defined $candidate->{'name'} && defined $param->{'name'} && $candidate->{'name'} eq $param->{'name'}
defined $candidate->{"name"} defined $param->{"name"} $candidate->{'name'} eq $param->{'name'}
Truth table75%3/4
A and B && C
A= defined $candidate->{"name"}B= defined $param->{"name"}C= $candidate->{'name'} eq $param->{'name'}
ABCresult
0XX0
10X0
1100
1111
156 21 ▶ my $by_position = !defined $candidate->{name} && defined $candidate->{index} && $candidate->{index} == $param->{index};
Condition100%6/6
!defined($candidate->{'name'}) && defined $candidate->{'index'} && $candidate->{'index'} == $param->{'index'}
!ll&&!rl&&r
1524
not defined $candidate->{"name"} and defined $candidate->{"index"}
!ll&&!rl&&r
876
MC/DC100%3/3
!defined($candidate->{'name'}) && defined $candidate->{'index'} && $candidate->{'index'} == $param->{'index'}
not defined $candidate->{"name"} defined $candidate->{"index"} $candidate->{'index'} == $param->{'index'}
Truth table100%4/4
not(A) and B && C
A= not defined $candidate->{"name"}B= defined $candidate->{"index"}C= $candidate->{'index'} == $param->{'index'}
ABCresult
0XX0
10X0
1100
1111
157 21 ▶ next if !$by_name && !$by_position;
Branch: 1 branch
BranchTrueFalseTotal
unless $by_name or $by_position 13 8 21
Condition100%3/3
$by_name or $by_position
l!l&&r!l&&!r
4413
MC/DC100%2/2
$by_name or $by_position
$by_name $by_position
Truth table100%3/3
A or B
A= $by_nameB= $by_position
ABresult
1X1
011
000
158 8 $param->{declared} = $candidate->{type};
159 8 $param->{declared_by} = $declaration->{via};
160 8 last;
161 }
162 }
163 23 return;
164 }
165  
166  
167 # The record of what the op tree of C<code> shows, as RECORDS describes it.
168 # @param code CodeRef the sub
169 # @param name Str the name of the sub
170 # @param package Str the package that the sub belongs to
171 # @returns HashRef the record
172 # @example my $record = $analyzer->analyze_sub( \&Pod::Coverage::More::coverage, 'coverage', 'Pod::Coverage::More' );
173 359 ▶sub analyze_sub {
Subroutine analyze_sub: called CC=17 SCAR=28.4
Pod documented
174 359 my ( $self, $code, $name, $package ) = @_;
175  
176 359 my $cv = B::svref_2object($code);
177 359 my %rec = (
178 name => $name,
179 package => $package,
180 file => $cv->FILE,
181 generated => _is_generated( $cv, $name, $package ),
182 method => 0,
183 signature => 0,
184 reads_args => 0,
185 params => [],
186 usage => {},
187 returns => [],
188 dies => [],
189 );
190  
191 359 ▶ if ( $cv->CvFLAGS & B::CVf_CONST ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv->CvFLAGS & 4) 6 353 359
192 6 $rec{kind} = 'constant';
193 6 $rec{value} = $code->();
194 6 my $returned = _sv_evidence( B::svref_2object( \$rec{value} ) );
195 6 push @{ $rec{returns} }, { %$returned, constraint => type_of_value($returned) };
196 6 return \%rec;
197 }
198 353 ▶ if ( $cv->XSUB ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cv->XSUB) 7 346 353
199 7 $rec{kind} = 'xs';
200 7 return \%rec;
201 }
202 346 $rec{kind} = 'perl';
203  
204 # The state of one walk lives on a copy of the analyzer, which shares its caches.
205 346 ▶ $self->{handlers} //= $self->op_handlers;
Condition66%2/3
$self->{"handlers"} //= $self->op_handlers
l!l&&r!l&&!r
321250
MC/DC0%0/2
$self->{"handlers"} //= $self->op_handlers
$self->{"handlers"} $self->op_handlers
Truth table66%2/3
A //= B
A= $self->{"handlers"}B= $self->op_handlers
ABresult
1X1
011
000
206 346 ▶ $self->{classifiers} //= $self->op_classifiers;
Condition66%2/3
$self->{"classifiers"} //= $self->op_classifiers
l!l&&r!l&&!r
321250
MC/DC0%0/2
$self->{"classifiers"} //= $self->op_classifiers
$self->{"classifiers"} $self->op_classifiers
Truth table66%2/3
A //= B
A= $self->{"classifiers"}B= $self->op_classifiers
ABresult
1X1
011
000
207 346 my $walker = bless {
208 %$self,
209 cv => $cv,
210 rec => \%rec,
211 shifted => 0,
212 consumed => {},
213 line_of => {},
214 line => undef,
215 signature => undef,
216 checkers => {},
217 guards => {},
218 big => undef,
219 big_of => {},
220 },
221 ref $self;
222  
223 346 $walker->_walk( $cv->ROOT, [] );
224 346 push @{ $rec{returns} }, map { +{ %$_, implicit => 1 } } $walker->_implicit_returns( $cv->ROOT );
225 346 $walker->finish_sub( \%rec );
226  
227 # A class taken from the invocant is the package or a subclass, and an object of either is an instance of the package.
228 346 ▶ my ($invocant) = grep { $_->{index} == 0 && defined $_->{name} } @{ $rec{params} };
Condition100%3/3
$_->{'index'} == 0 && defined $_->{'name'}
!ll&&!rl&&r
13815226
MC/DC100%2/2
$_->{'index'} == 0 && defined $_->{'name'}
$_->{'index'} == 0 defined $_->{'name'}
Truth table100%3/3
A && B
A= $_->{'index'} == 0B= defined $_->{'name'}
ABresult
0X0
100
111
229 346 foreach my $returned ( @{ $rec{returns} } ) {
230 $returned->{class} //= $package
231 384 ▶ if $invocant && $returned->{type} eq 'object' && ( $returned->{class_from} // q{} ) eq $invocant->{name};
Branch: 1 branch
BranchTrueFalseTotal
if $invocant and $returned->{"type"} eq "object" and ($returned->{"class_from"} // "") eq $invocant->{"name"} 6 378 384
Condition81%9/11
$invocant and $returned->{"type"} eq "object" and ($returned->{"class_from"} // "") eq $invocant->{"name"}
!ll&&!rl&&r
37176
$invocant and $returned->{"type"} eq "object"
!ll&&!rl&&r
12524613
$returned->{"class_from"} // ""
l!l
85
$returned->{"class"} //= $package
l!l&&r!l&&!r
060
MC/DC100%3/3
$invocant and $returned->{"type"} eq "object" and ($returned->{"class_from"} // "") eq $invocant->{"name"}
$invocant $returned->{"type"} eq "object" $returned->{"class_from"}
MC/DC0%0/2
$returned->{"class"} //= $package
$returned->{"class"} $package
Truth table100%4/4
A and B and C
A= $invocantB= $returned->{"type"} eq "object"C= $returned->{"class_from"}
ABCresult
0XX0
10X0
1100
1111
Truth table33%1/3
A //= B
A= $returned->{"class"}B= $package
ABresult
1X1
011
000
232 384 $returned->{constraint} = type_of_value($returned);
233 }
234 346 @{ $rec{params} } = sort { $a->{index} <=> $b->{index} } @{ $rec{params} };
235 346 foreach my $param ( @{ $rec{params} } ) {
236 379 ▶ next unless defined $param->{name};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $param->{"name"} 35 344 379
237 344 my $keys = $rec{usage}{ $param->{name} }{keys};
238 344 ▶ $param->{keys} = [@$keys] if $keys;
Branch: 1 branch
BranchTrueFalseTotal
if $keys 35 309 344
239 344 ▶ $param->{inferred} = type_of_usage( $rec{usage}{ $param->{name} } || {} );
Condition50%1/2
$rec{'usage'}{$param->{'name'}} || {}
l!l
3440
MC/DC0%0/1
$rec{'usage'}{$param->{'name'}} || {}
$rec{'usage'}{$param->{'name'}}
Truth table50%1/2
A
A= $rec{'usage'}{$param->{'name'}}
Aresult
11
00
240 344 ▶ if ( my $guard = $walker->{guards}{ $param->{name} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $guard = $walker->{"guards"}{$param->{"name"}}) 20 324 344
241 20 $param->{declared} = $guard->{type};
242 20 $param->{declared_by} = $guard->{by};
243 }
244 }
245 346 return \%rec;
246 }
247  
248 # Called once the op tree of a sub was walked, before the parameters are sorted.
249 # Subclasses override it to add what only the whole tree shows. The default does nothing.
250 # @param record HashRef the record of the sub, as RECORDS describes it
251 # @returns nothing
252 # @example $walker->finish_sub( \%record );
253 0 ▶sub finish_sub {
Subroutine finish_sub: not called CC=1 SCAR=6.9
Pod documented
254 0 return;
255 }
256  
257 # The methods that the walk calls for each op, with the op and the ARRAYREF of its ancestors, nearest last.
258 # Subclasses add the ops of their version set to what this returns.
259 # @returns HashRef from the name of each op to the name of its method
260 # @example my $handlers = $analyzer->op_handlers;
261 25 ▶sub op_handlers {
Subroutine op_handlers: called CC=1 SCAR=0.0
Pod documented
262 return {
263 25 nextstate => \&_on_cop,
264 dbstate => \&_on_cop,
265 sassign => \&_on_sassign,
266 aassign => \&_on_aassign,
267 shift => \&_on_shift,
268 aelemfast => \&_on_aelemfast,
269 padsv => \&_on_pad,
270 padav => \&_on_pad,
271 padhv => \&_on_pad,
272 rv2av => \&_on_rv2av,
273 multideref => \&_on_multideref,
274 helem => \&_on_helem,
275 exists => \&_on_exists,
276 delete => \&_on_exists,
277 entersub => \&_on_entersub,
278 return => \&_on_return,
279 die => \&_on_die,
280 exit => \&_on_die,
281 };
282 }
283  
284 # The methods that C<classify> calls for some ops, ahead of its own rules.
285 # Subclasses add the value-producing ops of their version set here, as they add walk handlers in C<op_handlers>.
286 # The default has none.
287 # @returns HashRef from the name of each op to the name of its method
288 # @example my $classifiers = $analyzer->op_classifiers;
289 25 ▶sub op_classifiers {
Subroutine op_classifiers: called CC=1 SCAR=0.0
Pod documented
290 25 return {};
291 }
292  
293 # The kids of C<op>, in order, for the handlers of subclasses.
294 # @param op B::OP the op
295 # @returns the kids, as a list of B::OP objects
296 # @example my @kids = $self->op_kids($op);
297 6832 ▶sub op_kids {
Subroutine op_kids: called CC=1 SCAR=0.0
Pod documented
298 6832 my ( undef, $op ) = @_;
299 6832 return _kids($op);
300 }
301  
302 # Whether something other than the source of PACKAGE wrote the sub: a closure installed under another name,
303 # a string eval, or a sub compiled in another file, as a class builder compiles accessors.
304 359 ▶sub _is_generated {
Subroutine _is_generated: called CC=5 SCAR=16.1
305 359 my ( $cv, $name, $package ) = @_;
306 359 ▶ return 1 if $cv->GV->NAME ne $name || $cv->FILE =~ m/\A\(eval/;
Branch: 1 branch
BranchTrueFalseTotal
if $cv->GV->NAME ne $name or $cv->FILE =~ /\A\(eval/aasx 8 351 359
Condition100%3/3
$cv->GV->NAME ne $name or $cv->FILE =~ /\A\(eval/aasx
l!l&&r!l&&!r
35351
MC/DC100%2/2
$cv->GV->NAME ne $name or $cv->FILE =~ /\A\(eval/aasx
$cv->GV->NAME ne $name $cv->FILE =~ /\A\(eval/aasx
Truth table100%3/3
A or B
A= $cv->GV->NAME ne $nameB= $cv->FILE =~ /\A\(eval/aasx
ABresult
1X1
011
000
307 351 my $own = $INC{ module_notional_filename($package) };
308 351 ▶ return ( defined $own && $cv->FILE ne $own ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $own && $cv->FILE ne $own ? : 22 329 351
Condition66%2/3
defined $own and $cv->FILE ne $own
!ll&&!rl&&r
032922
MC/DC50%1/2
defined $own and $cv->FILE ne $own
defined $own $cv->FILE ne $own
Truth table66%2/3
A and B
A= defined $ownB= $cv->FILE ne $own
ABresult
0X0
100
111
309 }
310  
311 # The package the sub was compiled in, as opposed to the one it was imported into.
312 426 ▶sub _defined_in {
Subroutine _defined_in: called CC=2 SCAR=7.0
313 426 my ($cv) = @_;
314 426 my $gv = $cv->GV;
315 426 ▶ return '' if B::class($gv) ne 'GV';
Branch: 1 branch
BranchTrueFalseTotal
if B::class($gv) ne "GV" 0 426 426
316 426 return $gv->STASH->NAME;
317 }
318  
319 # These subs walk an op tree, which is as deep as the nesting of the source, and so recursion is their natural form.
320 ## no critic (Subroutines::ProhibitTailRecursion)
321  
322 6715 ▶sub _walk {
Subroutine _walk: called CC=5 SCAR=16.1
323 6715 my ( $self, $op, $ancestors ) = @_;
324 6715 ▶ return if !$$op;
Branch: 1 branch
BranchTrueFalseTotal
unless $$op 0 6715 6715
325  
326 6715 $self->{line_of}{$$op} = $self->{line};
327 6715 $self->{big_of}{$$op} = $self->{big};
328  
329 6715 my $handler = $self->{handlers}{ $op->name };
330 6715 ▶ $self->$handler( $op, $ancestors ) if $handler;
Branch: 1 branch
BranchTrueFalseTotal
if $handler 2609 4106 6715
331  
332 6715 my @kids = $self->op_kids($op);
333 6715 ▶ return unless @kids;
Branch: 1 branch
BranchTrueFalseTotal
unless @kids 3476 3239 6715
334 3239 push @$ancestors, $op;
335 3239 foreach my $kid (@kids) {
336 6369 $self->_walk( $kid, $ancestors );
337 }
338 3239 pop @$ancestors;
339 3239 return;
340 }
341  
342 # The values a sub returns when control reaches its end without a return statement.
343 721 ▶sub _last_values {
Subroutine _last_values: called CC=27 SCAR=36.7
344 721 my ( $self, $op ) = @_;
345 721 ▶ return () if !$op || !$$op;
Branch: 1 branch
BranchTrueFalseTotal
unless $op and $$op 0 721 721
Condition33%1/3
$op and $$op
!ll&&!rl&&r
00721
MC/DC0%0/2
$op and $$op
$op $$op
Truth table33%1/3
A and B
A= $opB= $$op
ABresult
0X0
100
111
346 721 my $name = $op->name;
347  
348 721 ▶ if ( $name eq 'lineseq' || $name eq 'scope' || $name eq 'leave' || $name eq 'null' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "lineseq" or $name eq "scope" or $name eq "leave" or $name eq "null") 363 358 721
Condition88%8/9
$name eq "lineseq" or $name eq "scope" or $name eq "leave" or $name eq "null"
l!l&&r!l&&!r
35112358
$name eq "lineseq" or $name eq "scope" or $name eq "leave"
l!l&&r!l&&!r
34110370
$name eq "lineseq" or $name eq "scope"
l!l&&r!l&&!r
3410380
MC/DC75%3/4
$name eq "lineseq" or $name eq "scope" or $name eq "leave" or $name eq "null"
$name eq "lineseq" $name eq "scope" $name eq "leave" $name eq "null"
Truth table80%4/5
A or B or C or D
A= $name eq "lineseq"B= $name eq "scope"C= $name eq "leave"D= $name eq "null"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
349 363 my @kids;
350 363 foreach my $kid ( _significant_kids($op) ) {
351 1391 ▶ push @kids, $kid unless $kid->name eq 'nextstate' || $kid->name eq 'dbstate' || $kid->name eq 'enter';
Branch: 1 branch
BranchTrueFalseTotal
unless $kid->name eq "nextstate" or $kid->name eq "dbstate" or $kid->name eq "enter" 728 663 1391
Condition83%5/6
$kid->name eq "nextstate" or $kid->name eq "dbstate" or $kid->name eq "enter"
l!l&&r!l&&!r
65310728
$kid->name eq "nextstate" or $kid->name eq "dbstate"
l!l&&r!l&&!r
6530738
MC/DC66%2/3
$kid->name eq "nextstate" or $kid->name eq "dbstate" or $kid->name eq "enter"
$kid->name eq "nextstate" $kid->name eq "dbstate" $kid->name eq "enter"
Truth table75%3/4
A or B or C
A= $kid->name eq "nextstate"B= $kid->name eq "dbstate"C= $kid->name eq "enter"
ABCresult
1XX1
01X1
0011
0000
352 }
353 363 ▶ return () if !@kids && $name ne 'null';
Branch: 1 branch
BranchTrueFalseTotal
if not @kids and $name ne "null" 0 363 363
Condition33%1/3
not @kids and $name ne "null"
!ll&&!rl&&r
36300
MC/DC0%0/2
not @kids and $name ne "null"
not @kids $name ne "null"
Truth table33%1/3
not(A) and B
A= not @kidsB= $name ne "null"
ABresult
0X0
100
111
354 363 ▶ return $self->classify($op) if !@kids;
Branch: 1 branch
BranchTrueFalseTotal
unless @kids 0 363 363
355  
356 # A null op that wraps one expression is that expression.
357 363 ▶ return $self->_last_values( $kids[-1] ) if $name ne 'null' || @kids == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $name ne "null" or @kids == 1 363 0 363
Condition66%2/3
$name ne "null" or @kids == 1
l!l&&r!l&&!r
351120
MC/DC0%0/2
$name ne "null" or @kids == 1
$name ne "null" @kids == 1
Truth table66%2/3
A or B
A= $name ne "null"B= @kids == 1
ABresult
1X1
011
000
358 0 return $self->classify($op);
359 }
360 358 ▶ if ( $name eq 'cond_expr' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "cond_expr") 7 351 358
361 7 my $line = $self->{line_of}{$$op};
362 7 my @values;
363 7 foreach my $branch ( ( _branches($op) )[ 1, 2 ] ) {
364 14 ▶ push @values, _is_empty_list($branch) ? { type => 'empty', line => $line } : $self->_last_values($branch);
Branch: 1 branch
BranchTrueFalseTotal
_is_empty_list($branch) ? : 2 12 14
365 }
366 7 return @values;
367 }
368 351 ▶ if ( $name eq 'and' || $name eq 'or' || $name eq 'dor' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "and" or $name eq "or" or $name eq "dor") 0 351 351
Condition33%2/6
$name eq "and" or $name eq "or" or $name eq "dor"
l!l&&r!l&&!r
00351
$name eq "and" or $name eq "or"
l!l&&r!l&&!r
00351
MC/DC0%0/3
$name eq "and" or $name eq "or" or $name eq "dor"
$name eq "and" $name eq "or" $name eq "dor"
Truth table25%1/4
A or B or C
A= $name eq "and"B= $name eq "or"C= $name eq "dor"
ABCresult
1XX1
01X1
0011
0000
369  
370 # if (COND) { BODY } without an else: COND's value when the body does not run.
371 0 my ( $cond, $body ) = _kids($op);
372 0 return ( $self->classify($cond), $self->_last_values($body) );
373 }
374 351 ▶ return () if $name eq 'return' || $name eq 'die' || $name eq 'exit' || $name eq 'stub';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "return" or $name eq "die" or $name eq "exit" or $name eq "stub" 325 26 351
Condition77%7/9
$name eq "return" or $name eq "die" or $name eq "exit" or $name eq "stub"
l!l&&r!l&&!r
325026
$name eq "return" or $name eq "die" or $name eq "exit"
l!l&&r!l&&!r
325026
$name eq "return" or $name eq "die"
l!l&&r!l&&!r
321426
MC/DC50%2/4
$name eq "return" or $name eq "die" or $name eq "exit" or $name eq "stub"
$name eq "return" $name eq "die" $name eq "exit" $name eq "stub"
Truth table60%3/5
A or B or C or D
A= $name eq "return"B= $name eq "die"C= $name eq "exit"D= $name eq "stub"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
375  
376 26 my $line = $self->{line_of}{$$op};
377 26 ▶ return ( { type => 'unknown', op => 'loop', line => $line } ) if $name eq 'leaveloop';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "leaveloop" 0 26 26
378 26 return map { +{ %$_, line => $line } } $self->classify($op);
379 }
380  
381 # The evidence that C<op>, an op that produces a value, gives about that value.
382 # It is one HASHREF per alternative, because an expression such as C<COND ? A : B> has more than one.
383 #
384 # The C<type> of each is one of C<undef>, C<empty>, C<number>, C<string>, C<boolean>, C<hashref>, C<arrayref>, C<coderef>, C<ref>,
385 # C<object>, C<variable>, C<call>, C<method>, C<list>, C<context> or C<unknown>.
386 # @param op B::OP the op that produces the value
387 # @returns the evidence, as a list of HASHREFs
388 # @example my @evidence = $self->classify($op);
389 343 ▶sub classify {
Subroutine classify: called CC=36 SCAR=37.2
Pod documented
390 343 my ( $self, $op ) = @_;
391 343 ▶ return { type => 'empty' } if _is_empty_list($op);
Branch: 1 branch
BranchTrueFalseTotal
if _is_empty_list($op) 6 337 343
392 337 $op = _unwrap($op);
393 337 my $name = $op->name;
394  
395 337 my $classifier = $self->{classifiers}{$name};
396 337 ▶ return $self->$classifier($op) if $classifier;
Branch: 1 branch
BranchTrueFalseTotal
if $classifier 13 324 337
397  
398 324 ▶ return _sv_evidence( $self->_const_sv($op) ) if $name eq 'const';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "const" 79 245 324
399 245 ▶ return { type => 'undef' } if $name eq 'undef';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "undef" 11 234 245
400 234 ▶ return { type => 'hashref' } if $name eq 'anonhash';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "anonhash" 3 231 234
401 231 ▶ return { type => 'arrayref' } if $name eq 'anonlist';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "anonlist" 24 207 231
402 207 ▶ return { type => 'coderef' } if $name eq 'anoncode';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "anoncode" 0 207 207
403 207 ▶ return { type => 'context' } if $name eq 'wantarray';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "wantarray" 0 207 207
404  
405 207 ▶ return $self->_classify_refgen($op) if $name eq 'srefgen' || $name eq 'refgen';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "srefgen" or $name eq "refgen" 0 207 207
Condition33%1/3
$name eq "srefgen" or $name eq "refgen"
l!l&&r!l&&!r
00207
MC/DC0%0/2
$name eq "srefgen" or $name eq "refgen"
$name eq "srefgen" $name eq "refgen"
Truth table33%1/3
A or B
A= $name eq "srefgen"B= $name eq "refgen"
ABresult
1X1
011
000
406 207 ▶ return $self->_classify_bless($op) if $name eq 'bless';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "bless" 21 186 207
407  
408 186 ▶ if ( $name eq 'scalar' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "scalar") 7 179 186
409 7 my ($kid) = _significant_kids($op);
410 7 ▶ return { type => 'unknown', op => $name } if !$kid;
Branch: 1 branch
BranchTrueFalseTotal
unless $kid 0 7 7
411 7 my $kname = _unwrap($kid)->name;
412 7 ▶ return { type => 'number', integer => 1 } if $kname eq 'padav' || $kname eq 'rv2av';
Branch: 1 branch
BranchTrueFalseTotal
if $kname eq "padav" or $kname eq "rv2av" 6 1 7
Condition100%3/3
$kname eq "padav" or $kname eq "rv2av"
l!l&&r!l&&!r
241
MC/DC100%2/2
$kname eq "padav" or $kname eq "rv2av"
$kname eq "padav" $kname eq "rv2av"
Truth table100%3/3
A or B
A= $kname eq "padav"B= $kname eq "rv2av"
ABresult
1X1
011
000
413 1 return $self->classify($kid);
414 }
415 179 ▶ if ( $name eq 'padsv' || $name eq 'padav' || $name eq 'padhv' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "padsv" or $name eq "padav" or $name eq "padhv") 32 147 179
Condition83%5/6
$name eq "padsv" or $name eq "padav" or $name eq "padhv"
l!l&&r!l&&!r
320147
$name eq "padsv" or $name eq "padav"
l!l&&r!l&&!r
302147
MC/DC66%2/3
$name eq "padsv" or $name eq "padav" or $name eq "padhv"
$name eq "padsv" $name eq "padav" $name eq "padhv"
Truth table75%3/4
A or B or C
A= $name eq "padsv"B= $name eq "padav"C= $name eq "padhv"
ABCresult
1XX1
01X1
0011
0000
416 32 return { type => 'variable', name => $self->_padname( $op->targ ) };
417 }
418 147 ▶ if ( $name eq 'sassign' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "sassign") 3 144 147
419 3 my ($value) = _kids($op);
420 3 return $self->classify($value);
421 }
422 144 ▶ if ( $name eq 'cond_expr' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "cond_expr") 25 119 144
423 25 my ( $cond, $then, $else ) = _branches($op);
424  
425 # wantarray ? LIST : SCALAR says which value goes with which context.
426 25 ▶ if ( _unwrap($cond)->name eq 'wantarray' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_unwrap($cond)->name eq "wantarray") 4 21 25
427 return (
428 4 ( map { +{ %$_, context => 'list' } } $self->classify($then) ),
429 4 ( map { +{ %$_, context => 'scalar' } } $self->classify($else) ),
430 );
431 }
432 21 return ( $self->classify($then), $self->classify($else) );
433 }
434 119 ▶ if ( $name eq 'or' || $name eq 'dor' || $name eq 'and' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "or" or $name eq "dor" or $name eq "and") 0 119 119
Condition33%2/6
$name eq "or" or $name eq "dor" or $name eq "and"
l!l&&r!l&&!r
00119
$name eq "or" or $name eq "dor"
l!l&&r!l&&!r
00119
MC/DC0%0/3
$name eq "or" or $name eq "dor" or $name eq "and"
$name eq "or" $name eq "dor" $name eq "and"
Truth table25%1/4
A or B or C
A= $name eq "or"B= $name eq "dor"C= $name eq "and"
ABCresult
1XX1
01X1
0011
0000
435 0 my @evidence;
436 0 foreach my $kid ( _kids($op) ) {
437 0 push @evidence, $self->classify($kid);
438 }
439 0 return @evidence;
440 }
441 119 ▶ if ( $name eq 'entersub' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "entersub") 36 83 119
442 36 my ($target) = $self->_call_target($op);
443 36 ▶ return $target // { type => 'call' };
Condition50%1/2
$target // {"type", "call"}
l!l
360
MC/DC0%0/1
$target // {"type", "call"}
$target
Truth table50%1/2
A
A= $target
Aresult
11
00
444 }
445 83 ▶ return _weak( { type => 'boolean' } ) if $BOOLEAN_OPS{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $Pod::Coverage::More::Analyzer::BOOLEAN_OPS{$name} 0 83 83
446 83 ▶ if ( $NUMBER_OPS{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Pod::Coverage::More::Analyzer::NUMBER_OPS{$name}) 34 49 83
447  
448 # A return statement classifies its value before the walk reaches it, in the scope of the statement.
449 34 ▶ my $big = exists $self->{big_of}{$$op} ? $self->{big_of}{$$op} : $self->{big};
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'big_of'}{$$op} ? : 0 34 34
450 34 ▶ return { type => 'object', classes => $big, weak => 1 } if $big;
Branch: 1 branch
BranchTrueFalseTotal
if $big 1 33 34
451 33 ▶ return _weak( { type => 'number', integer => 1 } ) if $INTEGER_OPS{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $Pod::Coverage::More::Analyzer::INTEGER_OPS{$name} 0 33 33
452 33 ▶ return _weak( { type => 'number', integer => 1, maybe_undef => 1 } ) if $MAYBE_INTEGER_OPS{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $Pod::Coverage::More::Analyzer::MAYBE_INTEGER_OPS{$name} 1 32 33
453 32 return _weak( { type => 'number' } );
454 }
455 49 ▶ return _weak( { type => 'string' } ) if $STRING_RESULT_OPS{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $Pod::Coverage::More::Analyzer::STRING_RESULT_OPS{$name} 15 34 49
456 34 ▶ return { type => 'list' } if $LIST_OPS{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $Pod::Coverage::More::Analyzer::LIST_OPS{$name} 8 26 34
457 26 return { type => 'unknown', op => $name };
458 }
459  
460 ## use critic
461  
462 9060 ▶sub _kids {
Subroutine _kids: called CC=4 SCAR=13.9
463 9060 my ($op) = @_;
464 9060 ▶ return () unless $op->flags & B::OPf_KIDS;
Branch: 1 branch
BranchTrueFalseTotal
unless $op->flags & 4 3546 5514 9060
465 5514 my @kids;
466 5514 ▶ for ( my $kid = $op->first; $$kid; $kid = $kid->sibling ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$kid) 11213 0 11213
467 11213 push @kids, $kid;
468 11213 ▶ last unless $kid->moresib;
Branch: 1 branch
BranchTrueFalseTotal
unless $kid->moresib 5514 5699 11213
469 }
470 5514 return @kids;
471 }
472  
473 # The condition and the two branches of COND ? THEN : ELSE. Perl leaves a branch that is an empty list out of the
474 # op tree, so a missing branch comes back as undef: the one left is THEN when the jump of the op lands in it.
475 42 ▶sub _branches {
Subroutine _branches: called CC=3 SCAR=11.0
476 42 my ($op) = @_;
477 42 my ( $cond, @branches ) = _kids($op);
478 42 ▶ return ( $cond, @branches ) if @branches != 1;
Branch: 1 branch
BranchTrueFalseTotal
if @branches != 1 34 8 42
479 8 ▶ return ( $cond, $branches[0], undef ) if _holds( $branches[0], $op->other );
Branch: 1 branch
BranchTrueFalseTotal
if _holds($branches[0], $op->other) 2 6 8
480 6 return ( $cond, undef, $branches[0] );
481 }
482  
483 # Whether OP is an empty list: a branch that perl left out of the op tree, as 5.44 does with the () of a ternary,
484 # or the stub op that older perls compile it to.
485 357 ▶sub _is_empty_list {
Subroutine _is_empty_list: called CC=2 SCAR=7.1
486 357 my ($op) = @_;
487 357 ▶ return !$op || $op->name eq 'stub';
Condition66%2/3
!$op || $op->name eq 'stub'
l!l&&r!l&&!r
80349
MC/DC50%1/2
!$op || $op->name eq 'stub'
!$op $op->name eq 'stub'
Truth table66%2/3
not(A) || B
A= !$opB= $op->name eq 'stub'
ABresult
1X1
011
000
488 }
489  
490 # Whether TARGET is OP or an op under it.
491 8 ▶sub _holds {
Subroutine _holds: called CC=3 SCAR=11.0
492 8 my ( $op, $target ) = @_;
493 8 my @ops = ($op);
494 8 ▶ while ( my $next = shift @ops ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $next = shift @ops) 12 6 18
495 12 ▶ return 1 if $$next == $$target;
Branch: 1 branch
BranchTrueFalseTotal
if $$next == $$target 2 10 12
496 10 push @ops, _kids($next);
497 }
498 6 return 0;
499 }
500  
501 # Kids that do something, as opposed to list markers and optimized-away ops.
502 1572 ▶sub _significant_kids {
Subroutine _significant_kids: called CC=6 SCAR=17.9
503 1572 my ($op) = @_;
504 1572 my @significant;
505 1572 foreach my $kid ( _kids($op) ) {
506 3784 my $name = $kid->name;
507 3784 ▶ next if $name eq 'pushmark' || $name eq 'padrange';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "pushmark" or $name eq "padrange" 821 2963 3784
Condition100%3/3
$name eq "pushmark" or $name eq "padrange"
l!l&&r!l&&!r
6521692963
MC/DC100%2/2
$name eq "pushmark" or $name eq "padrange"
$name eq "pushmark" $name eq "padrange"
Truth table100%3/3
A or B
A= $name eq "pushmark"B= $name eq "padrange"
ABresult
1X1
011
000
508 2963 ▶ next if $name eq 'null' && !( $kid->flags & B::OPf_KIDS );
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "null" and not $kid->flags & 4 44 2919 2963
Condition100%3/3
$name eq "null" and not $kid->flags & 4
!ll&&!rl&&r
248943044
MC/DC100%2/2
$name eq "null" and not $kid->flags & 4
$name eq "null" not $kid->flags & 4
Truth table100%3/3
A and not(B)
A= $name eq "null"B= not $kid->flags & 4
ABresult
0X0
100
111
509 2919 push @significant, $kid;
510 }
511 1572 return @significant;
512 }
513  
514 # Unwrap ex-list and similar null ops that have one kid.
515 1136 ▶sub _unwrap {
Subroutine _unwrap: called CC=3 SCAR=11.0
516 1136 my ($op) = @_;
517 1136 ▶ while ( $op->name eq 'null' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op->name eq "null") 251 1136 1387
518 251 my @kids = _significant_kids($op);
519 251 ▶ last if @kids != 1;
Branch: 1 branch
BranchTrueFalseTotal
if @kids != 1 0 251 251
520 251 $op = $kids[0];
521 }
522 1136 return $op;
523 }
524  
525 1130 ▶sub _padname {
Subroutine _padname: called CC=4 SCAR=14.5
526 1130 my ( $self, $targ ) = @_;
527 1130 ▶ return undef if !$targ;
Branch: 1 branch
BranchTrueFalseTotal
unless $targ 22 1108 1130
528 1108 my $padname = $self->{cv}->PADLIST->ARRAYelt(0)->ARRAYelt($targ);
529 1108 ▶ return undef if !$padname || B::class($padname) eq 'SPECIAL';
Branch: 1 branch
BranchTrueFalseTotal
if not $padname or B::class($padname) eq "SPECIAL" 0 1108 1108
Condition33%1/3
not $padname or B::class($padname) eq "SPECIAL"
l!l&&r!l&&!r
001108
MC/DC0%0/2
not $padname or B::class($padname) eq "SPECIAL"
not $padname B::class($padname) eq "SPECIAL"
Truth table33%1/3
not(A) or B
A= not $padnameB= B::class($padname) eq "SPECIAL"
ABresult
1X1
011
000
530 1108 return $padname->PVX;
531 }
532  
533 0 ▶sub _padval {
Subroutine _padval: not called CC=1 SCAR=6.9
534 0 my ( $self, $index ) = @_;
535 0 return $self->{cv}->PADLIST->ARRAYelt(1)->ARRAYelt($index);
536 }
537  
538 # Under threaded perls, GVs and constants live in the pad instead of the op.
539 483 ▶sub _gv {
Subroutine _gv: called CC=2 SCAR=7.2
540 483 my ( $self, $op ) = @_;
541 483 ▶ return B::class($op) eq 'PADOP' ? $self->_padval( $op->padix ) : $op->gv;
Branch: 1 branch
BranchTrueFalseTotal
B::class($op) eq 'PADOP' ? : 0 483 483
542 }
543  
544 102 ▶sub _const_sv {
Subroutine _const_sv: called CC=2 SCAR=7.0
545 102 my ( $self, $op ) = @_;
546 102 my $sv = $op->sv;
547 102 ▶ $sv = $self->_padval( $op->targ ) unless $$sv;
Branch: 1 branch
BranchTrueFalseTotal
unless $$sv 0 102 102
548 102 return $sv;
549 }
550  
551 250 ▶sub _sv_value {
Subroutine _sv_value: called CC=6 SCAR=19.6
552 250 my ($sv) = @_;
553 250 my $class = B::class($sv);
554 250 ▶ return undef if $class eq 'SPECIAL' || $class eq 'NULL';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "SPECIAL" or $class eq "NULL" 0 250 250
Condition33%1/3
$class eq "SPECIAL" or $class eq "NULL"
l!l&&r!l&&!r
00250
MC/DC0%0/2
$class eq "SPECIAL" or $class eq "NULL"
$class eq "SPECIAL" $class eq "NULL"
Truth table33%1/3
A or B
A= $class eq "SPECIAL"B= $class eq "NULL"
ABresult
1X1
011
000
555 250 my $flags = $sv->FLAGS;
556 250 ▶ return $sv->PV if $flags & B::SVf_POK;
Branch: 1 branch
BranchTrueFalseTotal
if $flags & 1024 186 64 250
557 64 ▶ return $sv->NV if $flags & B::SVf_NOK;
Branch: 1 branch
BranchTrueFalseTotal
if $flags & 512 0 64 64
558 64 ▶ return $sv->IV if $flags & B::SVf_IOK;
Branch: 1 branch
BranchTrueFalseTotal
if $flags & 256 64 0 64
559 0 return undef;
560 }
561  
562 85 ▶sub _sv_evidence {
Subroutine _sv_evidence: called CC=6 SCAR=19.0
563 85 my ($sv) = @_;
564 85 my $class = B::class($sv);
565 85 ▶ return { type => 'undef' } if $class eq 'SPECIAL' || $class eq 'NULL';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "SPECIAL" or $class eq "NULL" 0 85 85
Condition33%1/3
$class eq "SPECIAL" or $class eq "NULL"
l!l&&r!l&&!r
0085
MC/DC0%0/2
$class eq "SPECIAL" or $class eq "NULL"
$class eq "SPECIAL" $class eq "NULL"
Truth table33%1/3
A or B
A= $class eq "SPECIAL"B= $class eq "NULL"
ABresult
1X1
011
000
566 85 my $flags = $sv->FLAGS;
567 85 ▶ return _reference_evidence( $sv->RV ) if $flags & B::SVf_ROK;
Branch: 1 branch
BranchTrueFalseTotal
if $flags & 2048 3 82 85
568 82 ▶ return { type => 'string', value => $sv->PV } if $flags & B::SVf_POK;
Branch: 1 branch
BranchTrueFalseTotal
if $flags & 1024 18 64 82
569 64 ▶ return { type => 'number', value => _sv_value($sv) } if $flags & ( B::SVf_IOK | B::SVf_NOK );
Branch: 1 branch
BranchTrueFalseTotal
if $flags & 768 64 0 64
570 0 return { type => 'undef' };
571 }
572  
573 # The result of an operator is only probable: an operand of a class that overloads the operator,
574 # such as Math::GMP, makes it an object of that class. So its EVIDENCE is weak.
575 48 ▶sub _weak {
Subroutine _weak: called CC=1 SCAR=0.0
576 48 my ($evidence) = @_;
577 48 return { %$evidence, weak => 1 };
578 }
579  
580 # A constant that holds a reference, as use bigint makes of every numeric literal, or use constant of a list.
581 3 ▶sub _reference_evidence {
Subroutine _reference_evidence: called CC=5 SCAR=21.7
582 3 my ($referent) = @_;
583 3 ▶ return { type => 'object', class => $referent->SvSTASH->NAME } if $referent->FLAGS & B::SVs_OBJECT;
Branch: 1 branch
BranchTrueFalseTotal
if $referent->FLAGS & 1048576 2 1 3
584 1 my $class = B::class($referent);
585 1 ▶ return { type => 'arrayref' } if $class eq 'AV';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "AV" 1 0 1
586 0 ▶ return { type => 'hashref' } if $class eq 'HV';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "HV" 0 0 0
587 0 ▶ return { type => 'coderef' } if $class eq 'CV';
Branch: 1 branch
BranchTrueFalseTotal
if $class eq "CV" 0 0 0
588 0 return { type => 'ref' };
589 }
590  
591 483 ▶sub _fullname {
Subroutine _fullname: called CC=2 SCAR=7.1
592 483 my ($gv) = @_;
593 483 ▶ return undef if B::class($gv) ne 'GV';
Branch: 1 branch
BranchTrueFalseTotal
if B::class($gv) ne "GV" 0 483 483
594 483 return $gv->STASH->NAME . '::' . $gv->NAME;
595 }
596  
597 # The name of the sub a call goes to, where it was defined rather than where it was imported to,
598 # so that an imported croak reads as Carp::croak.
599 95 ▶sub _sub_fullname {
Subroutine _sub_fullname: called CC=6 SCAR=21.6
600 95 my ($gv) = @_;
601 95 ▶ return undef if B::class($gv) ne 'GV';
Branch: 1 branch
BranchTrueFalseTotal
if B::class($gv) ne "GV" 0 95 95
602 95 my $cv = $gv->CV;
603 95 ▶ if ( $$cv && B::class($cv) eq 'CV' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$cv and B::class($cv) eq "CV") 95 0 95
Condition33%1/3
$$cv and B::class($cv) eq "CV"
!ll&&!rl&&r
0095
MC/DC0%0/2
$$cv and B::class($cv) eq "CV"
$$cv B::class($cv) eq "CV"
Truth table33%1/3
A and B
A= $$cvB= B::class($cv) eq "CV"
ABresult
0X0
100
111
604 95 my $origin = $cv->GV;
605 95 ▶ return _fullname($origin) if B::class($origin) eq 'GV' && $origin->NAME ne '__ANON__';
Branch: 1 branch
BranchTrueFalseTotal
if B::class($origin) eq "GV" and $origin->NAME ne "__ANON__" 95 0 95
Condition33%1/3
B::class($origin) eq "GV" and $origin->NAME ne "__ANON__"
!ll&&!rl&&r
0095
MC/DC0%0/2
B::class($origin) eq "GV" and $origin->NAME ne "__ANON__"
B::class($origin) eq "GV" $origin->NAME ne "__ANON__"
Truth table33%1/3
A and B
A= B::class($origin) eq "GV"B= $origin->NAME ne "__ANON__"
ABresult
0X0
100
111
606 }
607 0 return _fullname($gv);
608 }
609  
610 362 ▶sub _is_args_array {
Subroutine _is_args_array: called CC=5 SCAR=16.2
611 362 my ( $self, $op ) = @_;
612 362 $op = _unwrap($op);
613 362 ▶ return 0 unless $op->name eq 'rv2av';
Branch: 1 branch
BranchTrueFalseTotal
unless $op->name eq "rv2av" 4 358 362
614 358 my ($gvop) = _kids($op);
615 358 ▶ return 0 unless $gvop && $gvop->name eq 'gv';
Branch: 1 branch
BranchTrueFalseTotal
unless $gvop and $gvop->name eq "gv" 15 343 358
Condition66%2/3
$gvop and $gvop->name eq "gv"
!ll&&!rl&&r
015343
MC/DC50%1/2
$gvop and $gvop->name eq "gv"
$gvop $gvop->name eq "gv"
Truth table66%2/3
A and B
A= $gvopB= $gvop->name eq "gv"
ABresult
0X0
100
111
616 343 my $gv = $self->_gv($gvop);
617 343 ▶ return ( _fullname($gv) // '' ) eq 'main::_';
Condition50%1/2
_fullname($gv) // ""
l!l
3430
MC/DC0%0/1
_fullname($gv) // ""
_fullname($gv)
Truth table50%1/2
A
A= _fullname($gv)
Aresult
11
00
618 }
619  
620 # A shift or pop of @_. With no argument, the op has no kids at all.
621 78 ▶sub _is_args_shift {
Subroutine _is_args_shift: called CC=3 SCAR=11.2
622 78 my ( $self, $op ) = @_;
623 78 $op = _unwrap($op);
624 78 ▶ return 0 unless $op->name eq 'shift';
Branch: 1 branch
BranchTrueFalseTotal
unless $op->name eq "shift" 42 36 78
625 36 my @kids = _kids($op);
626 36 ▶ return 1 if !@kids;
Branch: 1 branch
BranchTrueFalseTotal
unless @kids 36 0 36
627 0 return $self->_is_args_array( $kids[0] );
628 }
629  
630 480 ▶sub _usage_of {
Subroutine _usage_of: called CC=2 SCAR=6.9
631 480 my ( $self, $var ) = @_;
632 480 ▶ return $self->{rec}{usage}{$var} //= {};
Condition100%2/2
$self->{"rec"}{"usage"}{$var} //= {}
l!l
192288
MC/DC100%1/1
$self->{"rec"}{"usage"}{$var} //= {}
$self->{"rec"}{"usage"}{$var}
Truth table100%2/2
A
A= $self->{"rec"}{"usage"}{$var}
Aresult
11
00
633 }
634  
635 384 ▶sub _add_param {
Subroutine _add_param: called CC=8 SCAR=20.8
636 384 my ( $self, %param ) = @_;
637 384 my $params = $self->{rec}{params};
638 384 ▶ return if defined $param{name} && any { ( $_->{name} // '' ) eq $param{name} } @$params;
Subroutine __ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
if defined $param{"name"} and &any(sub { ($_->{"name"} // "") eq $param{"name"}; } , @$params) 0 384 384
Condition80%4/5
defined $param{"name"} and &any(sub { ($_->{"name"} // "") eq $param{"name"}; } , @$params)
!ll&&!rl&&r
413430
$_->{"name"} // ""
l!l
1872
MC/DC0%0/2
defined $param{"name"} and &any(sub { ($_->{"name"} // "") eq $param{"name"}; } , @$params)
defined $param{"name"} &any(sub { ($_->{"name"} // "") eq $param{"name"}; } , @$params)
MC/DC100%1/1
$_->{"name"} // ""
$_->{"name"}
Truth table66%2/3
A and B
A= defined $param{"name"}B= &any(sub { ($_->{"name"} // "") eq $param{"name"}; } , @$params)
ABresult
0X0
100
111
Truth table100%2/2
A
A= $_->{"name"}
Aresult
11
00
639 384 ▶ return if !defined $param{name} && any { $_->{index} == $param{index} } @$params;
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if not defined $param{"name"} and &any(sub { $_->{"index"} == $param{"index"}; } , @$params) 6 378 384
Condition100%3/3
not defined $param{"name"} and &any(sub { $_->{"index"} == $param{"index"}; } , @$params)
!ll&&!rl&&r
343356
MC/DC100%2/2
not defined $param{"name"} and &any(sub { $_->{"index"} == $param{"index"}; } , @$params)
not defined $param{"name"} &any(sub { $_->{"index"} == $param{"index"}; } , @$params)
Truth table100%3/3
not(A) and B
A= not defined $param{"name"}B= &any(sub { $_->{"index"} == $param{"index"}; } , @$params)
ABresult
0X0
100
111
640 378 ▶ $param{slurpy} //= ( defined $param{name} && $param{name} =~ m/\A[@%]/ ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $param{'name'} && $param{'name'} =~ /\A[\@%]/aasx ? : 24 342 366
Condition100%5/5
$param{"slurpy"} //= defined $param{"name"} && $param{"name"} =~ /\A[\@%]/aasx ? 1 : 0
l!l
12366
defined $param{"name"} and $param{"name"} =~ /\A[\@%]/aasx
!ll&&!rl&&r
3530724
MC/DC100%1/1
$param{"slurpy"} //= defined $param{"name"} && $param{"name"} =~ /\A[\@%]/aasx ? 1 : 0
$param{"slurpy"}
Truth table100%2/2
A
A= $param{"slurpy"}
Aresult
11
00
641 378 push @$params, \%param;
642 378 return;
643 }
644  
645 877 ▶sub _on_cop {
Subroutine _on_cop: called CC=3 SCAR=11.0
646 877 my ( $self, $op ) = @_;
647 877 $self->{line} = $op->line;
648 877 ▶ $self->{rec}{line} //= $op->line;
Condition66%2/3
$self->{"rec"}{"line"} //= $op->line
l!l&&r!l&&!r
5313460
MC/DC0%0/2
$self->{"rec"}{"line"} //= $op->line
$self->{"rec"}{"line"} $op->line
Truth table66%2/3
A //= B
A= $self->{"rec"}{"line"}B= $op->line
ABresult
1X1
011
000
649  
650 877 my $hints = $op->hints_hash->HASH;
651 877 my ($pragma) = grep { $hints->{$_} } sort keys %BIG_CLASSES;
652 877 ▶ $self->{big} = $pragma ? $BIG_CLASSES{$pragma} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$pragma ? : 4 873 877
653 877 return;
654 }
655  
656 55 ▶sub _assign_from_args {
Subroutine _assign_from_args: called CC=5 SCAR=16.1
657 55 my ( $self, $value, $target_name ) = @_;
658 55 $value = _unwrap($value);
659 55 ▶ if ( $self->_is_args_shift($value) ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->_is_args_shift($value)) { } 16 39 55
elsif ($value->name eq 'aelemfast' and $self->_is_args_elem($value)) { } 7 32 39
elsif (() = $self->_defaulted_elem($value)) { } 7 25 32
660 16 $self->{consumed}{$$value} = 1;
661 16 $self->_add_param( name => $target_name, index => $self->{shifted}++, source => 'shift' );
662 }
663 ▶ elsif ( $value->name eq 'aelemfast' && $self->_is_args_elem($value) ) {
Condition66%2/3
$value->name eq "aelemfast" and $self->_is_args_elem($value)
!ll&&!rl&&r
3207
MC/DC50%1/2
$value->name eq "aelemfast" and $self->_is_args_elem($value)
$value->name eq "aelemfast" $self->_is_args_elem($value)
Truth table66%2/3
A and B
A= $value->name eq "aelemfast"B= $self->_is_args_elem($value)
ABresult
0X0
100
111
664 7 $self->{consumed}{$$value} = 1;
665 7 $self->_add_param( name => $target_name, index => _elem_index($value), source => 'element' );
666 }
667 elsif ( my ( $elem, $default, $mode ) = $self->_defaulted_elem($value) ) {
668 7 $self->{consumed}{$$elem} = 1;
669 7 $self->_add_param(
670 name => $target_name,
671 index => _elem_index($elem),
672 source => 'element',
673 optional => 1,
674 default => { mode => $mode, value => [ $self->classify($default) ] },
675 );
676 }
677 55 return;
678 }
679  
680 # $_[N] with a default: @_ > N ? $_[N] : DEFAULT, as Method::Signatures and hand-written code say it, or $_[N] // DEFAULT.
681 # Returns the element, the default, and how the default applies, or nothing.
682 32 ▶sub _defaulted_elem {
Subroutine _defaulted_elem: called CC=11 SCAR=24.3
683 32 my ( $self, $op ) = @_;
684 32 my $name = $op->name;
685 32 ▶ if ( $name eq 'cond_expr' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "cond_expr") 10 22 32
686 10 my ( undef, $then, $else ) = _branches($op);
687 10 ▶ $then = _unwrap($then) if $then;
Branch: 1 branch
BranchTrueFalseTotal
if $then 10 0 10
688 10 ▶ return ( $then, $else, q{=} ) if $then && $then->name eq 'aelemfast' && $self->_is_args_elem($then);
Branch: 1 branch
BranchTrueFalseTotal
if $then and $then->name eq "aelemfast" and $self->_is_args_elem($then) 5 5 10
Condition66%4/6
$then and $then->name eq "aelemfast" and $self->_is_args_elem($then)
!ll&&!rl&&r
505
$then and $then->name eq "aelemfast"
!ll&&!rl&&r
055
MC/DC33%1/3
$then and $then->name eq "aelemfast" and $self->_is_args_elem($then)
$then $then->name eq "aelemfast" $self->_is_args_elem($then)
Truth table50%2/4
A and B and C
A= $thenB= $then->name eq "aelemfast"C= $self->_is_args_elem($then)
ABCresult
0XX0
10X0
1100
1111
689 }
690 27 ▶ if ( $name eq 'dor' || $name eq 'or' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "dor" or $name eq "or") 3 24 27
Condition100%3/3
$name eq "dor" or $name eq "or"
l!l&&r!l&&!r
2124
MC/DC100%2/2
$name eq "dor" or $name eq "or"
$name eq "dor" $name eq "or"
Truth table100%3/3
A or B
A= $name eq "dor"B= $name eq "or"
ABresult
1X1
011
000
691 3 my ( $left, $right ) = _kids($op);
692 3 $left = _unwrap($left);
693 3 ▶ return ( $left, $right, $name eq 'dor' ? q{//=} : q{||=} ) if $left->name eq 'aelemfast' && $self->_is_args_elem($left);
Branch: 2 branches
BranchTrueFalseTotal
if $left->name eq "aelemfast" and $self->_is_args_elem($left) 2 1 3
$name eq 'dor' ? : 2 0 2
Condition66%2/3
$left->name eq "aelemfast" and $self->_is_args_elem($left)
!ll&&!rl&&r
102
MC/DC50%1/2
$left->name eq "aelemfast" and $self->_is_args_elem($left)
$left->name eq "aelemfast" $self->_is_args_elem($left)
Truth table66%2/3
A and B
A= $left->name eq "aelemfast"B= $self->_is_args_elem($left)
ABresult
0X0
100
111
694 }
695 25 return;
696 }
697  
698 # The assignment of one value to a lexical scalar: the value is the first kid, and the target the last.
699 34 ▶sub _on_sassign {
Subroutine _on_sassign: called CC=3 SCAR=11.0
700 34 my ( $self, $op ) = @_;
701 34 my @kids = _kids($op);
702 34 ▶ return if @kids != 2;
Branch: 1 branch
BranchTrueFalseTotal
if @kids != 2 3 31 34
703 31 my $target = _unwrap( $kids[1] );
704 31 ▶ return unless $target->name eq 'padsv';
Branch: 1 branch
BranchTrueFalseTotal
unless $target->name eq "padsv" 29 2 31
705 2 $self->_assign_from_args( $kids[0], $self->_padname( $target->targ ) );
706 2 return;
707 }
708  
709 # A list assignment to lexicals, from @_ or from one shift of it.
710 155 ▶sub _on_aassign {
Subroutine _on_aassign: called CC=15 SCAR=27.2
711 155 my ( $self, $op ) = @_;
712 155 my ( $rhs, $lhs ) = _kids($op);
713 155 ▶ return unless $rhs && $lhs;
Branch: 1 branch
BranchTrueFalseTotal
unless $rhs and $lhs 0 155 155
Condition33%1/3
$rhs and $lhs
!ll&&!rl&&r
00155
MC/DC0%0/2
$rhs and $lhs
$rhs $lhs
Truth table33%1/3
A and B
A= $rhsB= $lhs
ABresult
0X0
100
111
714  
715 155 my @values = _significant_kids($rhs);
716 155 my @targets;
717 155 foreach my $kid ( _significant_kids($lhs) ) {
718 234 ▶ push @targets, $kid if $kid->name =~ m/\Apad[ash]v\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $kid->name =~ /\Apad[ash]v\z/aasx 233 1 234
719 }
720 155 ▶ return if @values != 1 || !@targets;
Branch: 1 branch
BranchTrueFalseTotal
if @values != 1 or not @targets 1 154 155
Condition66%2/3
@values != 1 or not @targets
l!l&&r!l&&!r
01154
MC/DC50%1/2
@values != 1 or not @targets
@values != 1 not @targets
Truth table66%2/3
A or not(B)
A= @values != 1B= not @targets
ABresult
1X1
011
000
721  
722 154 ▶ if ( $self->_is_args_array( $values[0] ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->_is_args_array($values[0])) { } 150 4 154
elsif ($self->_is_args_shift($values[0])) { } 1 3 4
elsif (my $checked = $self->_checked_call($values[0])) { } 3 0 3
723 150 foreach my $target (@targets) {
724 226 my $name = $self->_padname( $target->targ );
725 226 ▶ if ( $target->name eq 'padsv' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target->name eq 'padsv') { } 204 22 226
726 204 $self->_add_param( name => $name, index => $self->{shifted}++, source => 'list' );
727 }
728 else {
729 22 $self->_add_param( name => $name, index => $self->{shifted}, source => 'list' );
730 22 last;
731 }
732 }
733 }
734 elsif ( $self->_is_args_shift( $values[0] ) ) {
735 1 $self->{consumed}{ ${ _unwrap( $values[0] ) } } = 1;
736 1 $self->_add_param( name => $self->_padname( $targets[0]->targ ), index => $self->{shifted}++, source => 'shift' );
737 }
738 elsif ( my $checked = $self->_checked_call( $values[0] ) ) {
739 3 my @types = @{ $checked->{types} };
740 3 foreach my $target (@targets) {
741 6 my $name = $self->_padname( $target->targ );
742 6 ▶ if ( $target->name ne 'padsv' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target->name ne "padsv") 1 5 6
743 1 $self->_add_param( name => $name, index => $self->{shifted}, source => 'checked' );
744 1 last;
745 }
746 5 my $type = shift @types;
747 $self->_add_param(
748 name => $name,
749 index => $self->{shifted}++,
750 source => 'checked',
751 5 ▶ $type ? ( declared => $type, declared_by => $checked->{by} ) : (),
Branch: 1 branch
BranchTrueFalseTotal
$type ? : 4 1 5
752 );
753 }
754 }
755 154 return;
756 }
757  
758 # A call that checks the arguments of the sub, such as $check->(@_), validate(\@_, ...) or validate_pos(@_, ...):
759 # returns the types it checks them against, by position, as far as the op tree shows them, or nothing when OP is no such call.
760 3 ▶sub _checked_call {
Subroutine _checked_call: called CC=11 SCAR=24.2
761 3 my ( $self, $op ) = @_;
762 3 $op = _unwrap($op);
763 3 ▶ return if $op->name ne 'entersub';
Branch: 1 branch
BranchTrueFalseTotal
if $op->name ne "entersub" 0 3 3
764 3 my ( $target, $args ) = $self->_call_target($op);
765 3 my @rest = @$args;
766 3 my $receives_args;
767 3 ▶ while ( my $arg = shift @rest ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $arg = shift @rest) 3 0 3
768 3 my $value = _unwrap($arg);
769 3 ▶ $value = _unwrap( ( _kids($value) )[0] ) if $value->name eq 'srefgen' && _kids($value);
Branch: 1 branch
BranchTrueFalseTotal
if $value->name eq "srefgen" and _kids($value) 1 2 3
Condition66%2/3
$value->name eq "srefgen" and _kids($value)
!ll&&!rl&&r
201
MC/DC50%1/2
$value->name eq "srefgen" and _kids($value)
$value->name eq "srefgen" _kids($value)
Truth table66%2/3
A and B
A= $value->name eq "srefgen"B= _kids($value)
ABresult
0X0
100
111
770 3 ▶ next if !$self->_is_args_array($value);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_args_array($value) 0 3 3
771 3 $receives_args = 1;
772 3 last;
773 }
774 3 ▶ return if !$receives_args;
Branch: 1 branch
BranchTrueFalseTotal
unless $receives_args 0 3 3
775  
776 3 ▶ if ( ( $target->{function} // q{} ) eq 'Type::Params::validate' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($target->{"function"} // "") eq "Type::Params::validate") 1 2 3
Condition100%2/2
$target->{"function"} // ""
l!l
21
MC/DC100%1/1
$target->{"function"} // ""
$target->{"function"}
Truth table100%2/2
A
A= $target->{"function"}
Aresult
11
00
777 1 return { types => $self->_try_static_values( \@rest ), by => 'Type::Params' };
778 }
779 2 ▶ my $checker = defined $target->{coderef} ? $self->{checkers}{ $target->{coderef} } : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $target->{'coderef'} ? : 1 1 2
780 2 ▶ return { types => [ @{ $checker // [] } ], by => 'Type::Params' };
Condition100%2/2
$checker // []
l!l
11
MC/DC100%1/1
$checker // []
$checker
Truth table100%2/2
A
A= $checker
Aresult
11
00
781 }
782  
783 # The value that OP builds from constants and calls to the type functions of a Type::Library, as in Optional[Str].
784 # Dies when OP builds anything else.
785 # It walks the op tree of one expression, and so recursion is its natural form.
786 ## no critic (Subroutines::ProhibitTailRecursion)
787 17 ▶sub _static_value {
Subroutine _static_value: called CC=11 SCAR=24.4
788 17 my ( $self, $op ) = @_;
789 17 $op = _unwrap($op);
790 17 my $name = $op->name;
791 17 ▶ return _sv_value( $self->_const_sv($op) ) if $name eq 'const';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "const" 5 12 17
792 12 ▶ if ( $name eq 'anonlist' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "anonlist") 2 10 12
793 2 my @values;
794 2 foreach my $kid ( _significant_kids($op) ) {
795 2 push @values, $self->_static_value($kid);
796 }
797 2 return \@values;
798 }
799 10 ▶ if ( $name eq 'entersub' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "entersub") 7 3 10
800 7 my ( $target, $args ) = $self->_call_target($op);
801 7 ▶ my ( $library, $type ) = ( $target->{function} // q{} ) =~ m/\A(.+)::(\w+)\z/;
Condition50%1/2
$target->{"function"} // ""
l!l
70
MC/DC0%0/1
$target->{"function"} // ""
$target->{"function"}
Truth table50%1/2
A
A= $target->{"function"}
Aresult
11
00
802 7 ▶ die "not a type\n" if !$type || !_is_type_library($library) || !$library->has_type($type);
Branch: 1 branch
BranchTrueFalseTotal
unless $type and _is_type_library($library) and $library->has_type($type) 0 7 7
Condition33%2/6
$type and _is_type_library($library) and $library->has_type($type)
!ll&&!rl&&r
007
$type and _is_type_library($library)
!ll&&!rl&&r
007
MC/DC0%0/3
$type and _is_type_library($library) and $library->has_type($type)
$type _is_type_library($library) $library->has_type($type)
Truth table25%1/4
A and B and C
A= $typeB= _is_type_library($library)C= $library->has_type($type)
ABCresult
0XX0
10X0
1100
1111
803 7 ▶ return $library->get_type($type) if !@$args;
Branch: 1 branch
BranchTrueFalseTotal
unless @$args 5 2 7
804 2 my @values;
805 2 foreach my $arg (@$args) {
806 2 push @values, $self->_static_value($arg);
807 }
808 2 return $library->can($type)->(@values);
809 }
810 3 die "not a static value\n";
811 }
812 ## use critic
813  
814 # The value of _static_value, or undef when OP builds anything else.
815 13 ▶sub _try_static_value {
Subroutine _try_static_value: called CC=2 SCAR=6.9
816 13 my ( $self, $op ) = @_;
817 13 my $value;
818 13 ▶ return eval { $value = $self->_static_value($op); 1 } ? $value : undef;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $value = $self->_static_value($op); 1 } } ? : 10 3 13
819 }
820  
821 # The values of _try_static_value for each op of the ARRAYREF OPS.
822 2 ▶sub _try_static_values {
Subroutine _try_static_values: called CC=2 SCAR=6.9
823 2 my ( $self, $ops ) = @_;
824 2 my @values;
825 2 foreach my $op (@$ops) {
826 4 push @values, $self->_try_static_value($op);
827 }
828 2 return \@values;
829 }
830  
831 25 ▶sub _is_type_library {
Subroutine _is_type_library: called CC=2 SCAR=7.0
832 25 my ($package) = @_;
833 25 my $is;
834 25 ▶ return eval { $is = $package->isa('Type::Library'); 1 } ? $is : 0;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $is = $package->isa('Type::Library'); 1 } } ? : 25 0 25
835 }
836  
837 # Records the types that compile() of Type::Params returns a checker for, under the variable the checker is assigned to.
838 1 ▶sub _note_checker {
Subroutine _note_checker: called CC=6 SCAR=21.8
839 1 my ( $self, $args, $ancestors ) = @_;
840 1 ▶ my $parent = $ancestors->[-1] // return;
Condition50%1/2
$ancestors->[-1] // (return)
l!l
10
MC/DC0%0/1
$ancestors->[-1] // (return)
$ancestors->[-1]
Truth table50%1/2
A
A= $ancestors->[-1]
Aresult
11
00
841 1 my $var;
842 1 ▶ $var = $self->_padname( $parent->targ ) if $parent->name eq 'padsv_store';
Branch: 1 branch
BranchTrueFalseTotal
if $parent->name eq "padsv_store" 1 0 1
843 1 ▶ if ( $parent->name eq 'sassign' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->name eq "sassign") 0 1 1
844 0 my ( undef, $target ) = _kids($parent);
845 0 $target = _unwrap($target);
846 0 ▶ $var = $self->_padname( $target->targ ) if $target->name eq 'padsv';
Branch: 1 branch
BranchTrueFalseTotal
if $target->name eq "padsv" 0 0 0
847 }
848 1 ▶ return if !defined $var;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $var 0 1 1
849 1 $self->{checkers}{$var} = $self->_try_static_values($args);
850 1 return;
851 }
852  
853 19 our %GUARD_METHODS = map { $_ => 1 } qw{assert_valid assert_return check};
854  
855 # Records the type that a guard checks a variable against: is_X($var) and assert_X($var) of a Type::Library,
856 # TYPE->assert_valid($var) and its kind, and the type_error() calls that Method::Signatures compiles.
857 132 ▶sub _note_guard {
Subroutine _note_guard: called CC=17 SCAR=29.0
858 132 my ( $self, $target, $args ) = @_;
859 132 my ( $type, $checked, $by );
860  
861 132 ▶ if ( defined $target->{function} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $target->{'function'}) { } 72 60 132
elsif ($target->{'type'} eq 'method' and defined $target->{'method'}) { } 48 24 72
862 72 my ( $library, $guard ) = $target->{function} =~ m/\A(.+)::(?:assert|is)_(\w+)\z/;
863 72 ▶ return if !$guard || !_is_type_library($library) || !$library->has_type($guard);
Branch: 1 branch
BranchTrueFalseTotal
unless $guard and _is_type_library($library) and $library->has_type($guard) 54 18 72
Condition66%4/6
$guard and _is_type_library($library) and $library->has_type($guard)
!ll&&!rl&&r
54018
$guard and _is_type_library($library)
!ll&&!rl&&r
54018
MC/DC33%1/3
$guard and _is_type_library($library) and $library->has_type($guard)
$guard _is_type_library($library) $library->has_type($guard)
Truth table50%2/4
A and B and C
A= $guardB= _is_type_library($library)C= $library->has_type($guard)
ABCresult
0XX0
10X0
1100
1111
864 18 ( $type, $checked, $by ) = ( $library->get_type($guard), $args->[0], 'Type::Tiny' );
865 }
866 ▶ elsif ( $target->{type} eq 'method' && defined $target->{method} ) {
Condition66%2/3
$target->{"type"} eq "method" and defined $target->{"method"}
!ll&&!rl&&r
12048
MC/DC50%1/2
$target->{"type"} eq "method" and defined $target->{"method"}
$target->{"type"} eq "method" defined $target->{"method"}
Truth table66%2/3
A and B
A= $target->{"type"} eq "method"B= defined $target->{"method"}
ABresult
0X0
100
111
867 48 ▶ my $invocant = $args->[0] // return;
Condition50%1/2
$args->[0] // (return)
l!l
480
MC/DC0%0/1
$args->[0] // (return)
$args->[0]
Truth table50%1/2
A
A= $args->[0]
Aresult
11
00
868 48 ▶ if ( $GUARD_METHODS{ $target->{method} } ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($Pod::Coverage::More::Analyzer::GUARD_METHODS{$target->{'method'}}) { } 5 43 48
elsif ($target->{'method'} eq 'type_error' and ($self->_try_static_value($invocant) // '') eq 'Method::Signatures') { } 2 82 84
869 5 $type = $self->_try_static_value($invocant);
870 5 ( $checked, $by ) = ( $args->[1], 'Type::Tiny' );
871 }
872 ▶ elsif ( $target->{method} eq 'type_error' && ( $self->_try_static_value($invocant) // q{} ) eq 'Method::Signatures' ) {
Condition60%3/5
$target->{"method"} eq "type_error" and ($self->_try_static_value($invocant) // "") eq "Method::Signatures"
!ll&&!rl&&r
4102
$self->_try_static_value($invocant) // ""
l!l
20
MC/DC50%1/2
$target->{"method"} eq "type_error" and ($self->_try_static_value($invocant) // "") eq "Method::Signatures"
$target->{"method"} eq "type_error" $self->_try_static_value($invocant)
Truth table66%2/3
A and B
A= $target->{"method"} eq "type_error"B= $self->_try_static_value($invocant)
ABresult
0X0
100
111
873 2 my $name = $self->_try_static_value( $args->[1] );
874 2 $type = type_named($name);
875 2 ( $checked, $by ) = ( $args->[2], 'Method::Signatures' );
876 }
877 }
878 78 ▶ return if !$type || !blessed($type) || !$checked;
Branch: 1 branch
BranchTrueFalseTotal
unless $type and builtin::blessed($type) and $checked 56 22 78
Condition66%4/6
$type and builtin::blessed($type) and $checked
!ll&&!rl&&r
56022
$type and builtin::blessed($type)
!ll&&!rl&&r
56022
MC/DC33%1/3
$type and builtin::blessed($type) and $checked
$type builtin::blessed($type) $checked
Truth table50%2/4
A and B and C
A= $typeB= builtin::blessed($type)C= $checked
ABCresult
0XX0
10X0
1100
1111
879 22 $checked = _unwrap($checked);
880 22 ▶ return if $checked->name ne 'padsv';
Branch: 1 branch
BranchTrueFalseTotal
if $checked->name ne "padsv" 1 21 22
881 21 ▶ my $var = $self->_padname( $checked->targ ) // return;
Condition50%1/2
$self->_padname($checked->targ) // (return)
l!l
210
MC/DC0%0/1
$self->_padname($checked->targ) // (return)
$self->_padname($checked->targ)
Truth table50%1/2
A
A= $self->_padname($checked->targ)
Aresult
11
00
882 21 $self->{guards}{$var} = { type => $type, by => $by };
883 21 return;
884 }
885  
886 # Any use of @_, as a sub that only passes it on makes.
887 205 ▶sub _on_rv2av {
Subroutine _on_rv2av: called CC=2 SCAR=6.9
888 205 my ( $self, $op ) = @_;
889 205 ▶ $self->{rec}{reads_args} = 1 if $self->_is_args_array($op);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_args_array($op) 190 15 205
890 205 return;
891 }
892  
893 # A shift of @_ that is not assigned to a variable, as in shift->method.
894 19 ▶sub _on_shift {
Subroutine _on_shift: called CC=3 SCAR=11.0
895 19 my ( $self, $op ) = @_;
896 19 ▶ return unless $self->_is_args_shift($op);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_args_shift($op) 0 19 19
897 19 $self->{rec}{reads_args} = 1;
898 19 ▶ return if $self->{consumed}{$$op};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"consumed"}{$$op} 17 2 19
899 2 $self->_add_param( name => undef, index => $self->{shifted}++, source => 'shift' );
900 2 return;
901 }
902  
903 45 ▶sub _is_args_elem {
Subroutine _is_args_elem: called CC=2 SCAR=7.1
904 45 my ( $self, $op ) = @_;
905 45 my $gv = $self->_gv($op);
906 45 ▶ return ( _fullname($gv) // '' ) eq 'main::_';
Condition50%1/2
_fullname($gv) // ""
l!l
450
MC/DC0%0/1
_fullname($gv) // ""
_fullname($gv)
Truth table50%1/2
A
A= _fullname($gv)
Aresult
11
00
907 }
908  
909 31 ▶sub _elem_index {
Subroutine _elem_index: called CC=1 SCAR=0.0
910 31 my ($op) = @_;
911 31 return unpack( 'c', pack( 'C', $op->private ) );
912 }
913  
914 # $_[N] used directly.
915 31 ▶sub _on_aelemfast {
Subroutine _on_aelemfast: called CC=4 SCAR=14.0
916 31 my ( $self, $op ) = @_;
917 31 ▶ return unless $self->_is_args_elem($op);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_args_elem($op) 0 31 31
918 31 $self->{rec}{reads_args} = 1;
919 31 ▶ return if $self->{consumed}{$$op};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"consumed"}{$$op} 14 17 31
920 17 my $index = _elem_index($op);
921 17 ▶ return if $index < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $index < 0 0 17 17
922 17 $self->_add_param( name => undef, index => $index, source => 'element' );
923 17 return;
924 }
925  
926 554 ▶sub _on_pad {
Subroutine _on_pad: called CC=9 SCAR=22.2
927 554 my ( $self, $op, $ancestors ) = @_;
928 554 ▶ my $var = $self->_padname( $op->targ ) // return;
Condition50%1/2
$self->_padname($op->targ) // (return)
l!l
5540
MC/DC0%0/1
$self->_padname($op->targ) // (return)
$self->_padname($op->targ)
Truth table50%1/2
A
A= $self->_padname($op->targ)
Aresult
11
00
929 554 ▶ my $parent = $ancestors->[-1] // return;
Condition50%1/2
$ancestors->[-1] // (return)
l!l
5540
MC/DC0%0/1
$ancestors->[-1] // (return)
$ancestors->[-1]
Truth table50%1/2
A
A= $ancestors->[-1]
Aresult
11
00
930 554 my $pname = $parent->name;
931  
932 # A declaration of the variable is not a use of it.
933 554 ▶ return if $op->private & B::OPpLVAL_INTRO;
Branch: 1 branch
BranchTrueFalseTotal
if $op->private & 128 240 314 554
934  
935 314 my $usage = $self->_usage_of($var);
936 314 ▶ if ( $pname eq 'rv2hv' ) { $usage->{hashref} = 1 }
Branch: 5 branches
BranchTrueFalseTotal
if ($pname eq 'rv2hv') { } 1 313 314
elsif ($pname eq 'rv2av') { } 12 301 313
elsif ($pname eq 'rv2cv') { } 0 301 301
elsif ($Pod::Coverage::More::Analyzer::NUMERIC_OPS{$pname}) { } 40 261 301
elsif ($Pod::Coverage::More::Analyzer::STRING_OPS{$pname}) { } 36 225 261
937 12 elsif ( $pname eq 'rv2av' ) { $usage->{arrayref} = 1 }
938 0 elsif ( $pname eq 'rv2cv' ) { $usage->{coderef} = 1 }
939 40 elsif ( $NUMERIC_OPS{$pname} ) { $usage->{numeric} = 1 }
940 36 elsif ( $STRING_OPS{$pname} ) { $usage->{string} = 1 }
941 314 return;
942 }
943  
944 106 ▶sub _add_key {
Subroutine _add_key: called CC=5 SCAR=16.1
945 106 my ( $self, $var, $key ) = @_;
946 106 ▶ return if !defined $var || !defined $key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $var and defined $key 20 86 106
Condition66%2/3
defined $var and defined $key
!ll&&!rl&&r
20086
MC/DC50%1/2
defined $var and defined $key
defined $var defined $key
Truth table66%2/3
A and B
A= defined $varB= defined $key
ABresult
0X0
100
111
947 86 my $usage = $self->_usage_of($var);
948 86 ▶ $usage->{keys} //= [];
Condition100%2/2
$usage->{"keys"} //= []
l!l
4937
MC/DC100%1/1
$usage->{"keys"} //= []
$usage->{"keys"}
Truth table100%2/2
A
A= $usage->{"keys"}
Aresult
11
00
949 86 ▶ push @{ $usage->{keys} }, $key unless any { $_ eq $key } @{ $usage->{keys} };
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
unless &any(sub { $_ eq $key; } , @{$$usage{"keys"};}) 55 31 86
950 86 return;
951 }
952  
953 # $h->{a}[0], $o{size}, exists $o{verbose} and the like, compiled into one op.
954 112 ▶sub _on_multideref {
Subroutine _on_multideref: called CC=18 SCAR=29.5
955 112 my ( $self, $op ) = @_;
956 112 my @items = $op->aux_list( $self->{cv} );
957 112 my $actions = shift @items;
958 112 my $first = 1;
959 112 my $var;
960  
961 112 while (1) {
962 132 my $action = $actions & B::MDEREF_ACTION_MASK;
963 132 ▶ if ( $action == B::MDEREF_reload ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action == 0) 0 132 132
964 0 $actions = shift @items;
965 0 next;
966 }
967 132 ▶ my $is_hash = any { $action == $_ } @HASH_MDEREF_ACTIONS;
Subroutine __ANON__: called CC=1 SCAR=0.0
968  
969 132 ▶ if ( $action == B::MDEREF_AV_padav_aelem || $action == B::MDEREF_HV_padhv_helem ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($action == 5 or $action == 12) { } 28 104 132
elsif ($action == 3 or $action == 10) { } 59 45 104
elsif ($action == 6 or $action == 13 or $action == 2 or $action == 9) { } 25 20 45
elsif (not $first) { } 20 0 20
Condition66%2/3
$action == 5 or $action == 12
l!l&&r!l&&!r
028104
MC/DC50%1/2
$action == 5 or $action == 12
$action == 5 $action == 12
Truth table66%2/3
A or B
A= $action == 5B= $action == 12
ABresult
1X1
011
000
970 28 $var = $self->_padname( shift @items );
971 }
972 ▶ elsif ( $action == B::MDEREF_AV_padsv_vivify_rv2av_aelem || $action == B::MDEREF_HV_padsv_vivify_rv2hv_helem ) {
Condition100%3/3
$action == 3 or $action == 10
l!l&&r!l&&!r
15845
MC/DC100%2/2
$action == 3 or $action == 10
$action == 3 $action == 10
Truth table100%3/3
A or B
A= $action == 3B= $action == 10
ABresult
1X1
011
000
973 59 $var = $self->_padname( shift @items );
974 59 ▶ $self->_usage_of($var)->{ $is_hash ? 'hashref' : 'arrayref' } = 1 if defined $var;
Branch: 2 branches
BranchTrueFalseTotal
if defined $var 59 0 59
$is_hash ? : 58 1 59
975 }
976 ▶ elsif ($action == B::MDEREF_AV_gvav_aelem
Condition77%7/9
$action == 6 or $action == 13 or $action == 2 or $action == 9
l!l&&r!l&&!r
25020
$action == 6 or $action == 13 or $action == 2
l!l&&r!l&&!r
25020
$action == 6 or $action == 13
l!l&&r!l&&!r
23220
MC/DC50%2/4
$action == 6 or $action == 13 or $action == 2 or $action == 9
$action == 6 $action == 13 $action == 2 $action == 9
Truth table60%3/5
A or B or C or D
A= $action == 6B= $action == 13C= $action == 2D= $action == 9
ABCDresult
1XXX1
01XX1
001X1
00011
00000
977 || $action == B::MDEREF_HV_gvhv_helem
978 || $action == B::MDEREF_AV_gvsv_vivify_rv2av_aelem
979 || $action == B::MDEREF_HV_gvsv_vivify_rv2hv_helem ) {
980 25 shift @items;
981 25 $var = undef;
982 }
983 elsif ( !$first ) {
984  
985 # A deeper level of a chain that started at $var: it says nothing more about $var itself.
986 20 $var = undef;
987 }
988  
989 132 my $index = $actions & B::MDEREF_INDEX_MASK;
990 132 ▶ last if $index == B::MDEREF_INDEX_none;
Branch: 1 branch
BranchTrueFalseTotal
if $index == 0 0 132 132
991 132 my $key = shift @items;
992 132 ▶ if ( $index == B::MDEREF_INDEX_const ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index == 16) 124 8 132
993 124 ▶ $self->_add_key( $var, ref $key ? _sv_value($key) : $key ) if $is_hash;
Branch: 2 branches
BranchTrueFalseTotal
if $is_hash 98 26 124
ref $key ? : 98 0 98
994 }
995  
996 132 ▶ last if $actions & B::MDEREF_FLAG_last;
Branch: 1 branch
BranchTrueFalseTotal
if $actions & 64 112 20 132
997 20 $actions >>= B::MDEREF_SHIFT;
998 20 $first = 0;
999 }
1000 112 return;
1001 }
1002  
1003 # $o{name} or $h->{name} when perl did not fold it into a multideref.
1004 8 ▶sub _on_helem {
Subroutine _on_helem: called CC=8 SCAR=23.4
1005 8 my ( $self, $op ) = @_;
1006 8 my ( $hash, $key ) = _kids($op);
1007 8 ▶ return unless $hash && $key && $key->name eq 'const';
Branch: 1 branch
BranchTrueFalseTotal
unless $hash and $key and $key->name eq "const" 0 8 8
Condition33%2/6
$hash and $key and $key->name eq "const"
!ll&&!rl&&r
008
$hash and $key
!ll&&!rl&&r
008
MC/DC0%0/3
$hash and $key and $key->name eq "const"
$hash $key $key->name eq "const"
Truth table25%1/4
A and B and C
A= $hashB= $keyC= $key->name eq "const"
ABCresult
0XX0
10X0
1100
1111
1008 8 my $var;
1009 8 ▶ if ( $hash->name eq 'padhv' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($hash->name eq 'padhv') { } 7 1 8
elsif ($hash->name eq 'rv2hv') { } 1 0 1
1010 7 $var = $self->_padname( $hash->targ );
1011 }
1012 elsif ( $hash->name eq 'rv2hv' ) {
1013 1 my ($ref) = _kids($hash);
1014 1 ▶ $var = $self->_padname( $ref->targ ) if $ref && $ref->name eq 'padsv';
Branch: 1 branch
BranchTrueFalseTotal
if $ref and $ref->name eq "padsv" 1 0 1
Condition33%1/3
$ref and $ref->name eq "padsv"
!ll&&!rl&&r
001
MC/DC0%0/2
$ref and $ref->name eq "padsv"
$ref $ref->name eq "padsv"
Truth table33%1/3
A and B
A= $refB= $ref->name eq "padsv"
ABresult
0X0
100
111
1015 }
1016 8 $self->_add_key( $var, _sv_value( $self->_const_sv($key) ) );
1017 8 return;
1018 }
1019  
1020 # exists $o{name} or delete $o{name} when perl did not fold it into a multideref:
1021 # the hash element is then a null op that was a helem.
1022 2 ▶sub _on_exists {
Subroutine _on_exists: called CC=4 SCAR=15.0
1023 2 my ( $self, $op ) = @_;
1024 2 my ($elem) = _kids($op);
1025 2 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 2 2
1026 2 ▶ return if $elem->name ne q{null} || $elem->targ != $HELEM;
Branch: 1 branch
BranchTrueFalseTotal
if $elem->name ne "null" or $elem->targ != $Pod::Coverage::More::Analyzer::HELEM 0 2 2
Condition33%1/3
$elem->name ne "null" or $elem->targ != $Pod::Coverage::More::Analyzer::HELEM
l!l&&r!l&&!r
002
MC/DC0%0/2
$elem->name ne "null" or $elem->targ != $Pod::Coverage::More::Analyzer::HELEM
$elem->name ne "null" $elem->targ != $Pod::Coverage::More::Analyzer::HELEM
Truth table33%1/3
A or B
A= $elem->name ne "null"B= $elem->targ != $Pod::Coverage::More::Analyzer::HELEM
ABresult
1X1
011
000
1027 2 $self->_on_helem($elem);
1028 2 return;
1029 }
1030  
1031 178 ▶sub _call_target {
Subroutine _call_target: called CC=11 SCAR=24.8
1032 178 my ( $self, $op ) = @_;
1033 178 my @args = _significant_kids($op);
1034 178 ▶ @args = _significant_kids( $args[0] ) if @args == 1 && $args[0]->name eq 'null';
Branch: 1 branch
BranchTrueFalseTotal
if @args == 1 and $args[0]->name eq "null" 109 69 178
Condition66%2/3
@args == 1 and $args[0]->name eq "null"
!ll&&!rl&&r
690109
MC/DC50%1/2
@args == 1 and $args[0]->name eq "null"
@args == 1 $args[0]->name eq "null"
Truth table66%2/3
A and B
A= @args == 1B= $args[0]->name eq "null"
ABresult
0X0
100
111
1035 178 my $target = pop @args;
1036 178 ▶ return ( undef, \@args ) if !$target;
Branch: 1 branch
BranchTrueFalseTotal
unless $target 0 178 178
1037  
1038 178 ▶ if ( $target->name eq 'method_named' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target->name eq "method_named") 65 113 178
1039 65 my $sv = $target->meth_sv;
1040 65 ▶ $sv = $self->_padval( $target->targ ) unless $$sv;
Branch: 1 branch
BranchTrueFalseTotal
unless $$sv 0 65 65
1041 65 return ( { type => 'method', method => _sv_value($sv) }, \@args );
1042 }
1043 113 ▶ if ( $target->name eq 'method' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target->name eq "method") 0 113 113
1044 0 return ( { type => 'method', method => undef }, \@args );
1045 }
1046 113 my $cvop = _unwrap($target);
1047 113 ▶ $cvop = _unwrap( ( _kids($cvop) )[0] ) if $cvop->name eq 'rv2cv' && _kids($cvop);
Branch: 1 branch
BranchTrueFalseTotal
if $cvop->name eq "rv2cv" and _kids($cvop) 0 113 113
Condition33%1/3
$cvop->name eq "rv2cv" and _kids($cvop)
!ll&&!rl&&r
11300
MC/DC0%0/2
$cvop->name eq "rv2cv" and _kids($cvop)
$cvop->name eq "rv2cv" _kids($cvop)
Truth table33%1/3
A and B
A= $cvop->name eq "rv2cv"B= _kids($cvop)
ABresult
0X0
100
111
1048 113 ▶ if ( $cvop->name eq 'gv' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cvop->name eq "gv") 95 18 113
1049 95 return ( { type => 'call', function => _sub_fullname( $self->_gv($cvop) ) }, \@args );
1050 }
1051 18 ▶ if ( $cvop->name eq 'padsv' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cvop->name eq "padsv") 9 9 18
1052 9 return ( { type => 'call', coderef => $self->_padname( $cvop->targ ) }, \@args );
1053 }
1054 9 return ( { type => 'call' }, \@args );
1055 }
1056  
1057 132 ▶sub _on_entersub {
Subroutine _on_entersub: called CC=10 SCAR=23.0
1058 132 my ( $self, $op, $ancestors ) = @_;
1059 132 my ( $target, $args ) = $self->_call_target($op);
1060 132 ▶ return if !$target;
Branch: 1 branch
BranchTrueFalseTotal
unless $target 0 132 132
1061  
1062 132 ▶ $self->_note_checker( $args, $ancestors ) if ( $target->{function} // q{} ) eq 'Type::Params::compile';
Branch: 1 branch
BranchTrueFalseTotal
if ($target->{"function"} // "") eq "Type::Params::compile" 1 131 132
Condition100%2/2
$target->{"function"} // ""
l!l
7260
MC/DC100%1/1
$target->{"function"} // ""
$target->{"function"}
Truth table100%2/2
A
A= $target->{"function"}
Aresult
11
00
1063 132 $self->_note_guard( $target, $args );
1064  
1065 132 ▶ if ( $target->{type} eq 'method' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target->{"type"} eq "method") 48 84 132
1066 48 $self->_add_method_use( $args->[0], $target->{method} );
1067 48 ▶ $self->_add_death( $target->{method}, $ancestors ) if $TERMINATING_METHODS{ $target->{method} // q{} };
Branch: 1 branch
BranchTrueFalseTotal
if $Pod::Coverage::More::Analyzer::TERMINATING_METHODS{$target->{"method"} // ""} 10 38 48
Condition50%1/2
$target->{"method"} // ""
l!l
480
MC/DC0%0/1
$target->{"method"} // ""
$target->{"method"}
Truth table50%1/2
A
A= $target->{"method"}
Aresult
11
00
1068 48 return;
1069 }
1070 84 ▶ if ( defined $target->{coderef} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $target->{"coderef"}) 6 78 84
1071 6 $self->_usage_of( $target->{coderef} )->{coderef} = 1;
1072 6 return;
1073 }
1074 78 ▶ if ( defined $target->{function} && $TERMINATORS{ $target->{function} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $target->{"function"} and $Pod::Coverage::More::Analyzer::TERMINATORS{$target->{"function"}}) 7 71 78
Condition100%3/3
defined $target->{"function"} and $Pod::Coverage::More::Analyzer::TERMINATORS{$target->{"function"}}
!ll&&!rl&&r
6657
MC/DC100%2/2
defined $target->{"function"} and $Pod::Coverage::More::Analyzer::TERMINATORS{$target->{"function"}}
defined $target->{"function"} $Pod::Coverage::More::Analyzer::TERMINATORS{$target->{"function"}}
Truth table100%3/3
A and B
A= defined $target->{"function"}B= $Pod::Coverage::More::Analyzer::TERMINATORS{$target->{"function"}}
ABresult
0X0
100
111
1075 7 $self->_add_death( $target->{function}, $ancestors );
1076 }
1077 78 return;
1078 }
1079  
1080 # Records METHOD as called on the variable that INVOCANT reads, when it reads one.
1081 48 ▶sub _add_method_use {
Subroutine _add_method_use: called CC=7 SCAR=20.9
1082 48 my ( $self, $invocant, $method ) = @_;
1083 48 ▶ return if !$invocant || !defined $method;
Branch: 1 branch
BranchTrueFalseTotal
unless $invocant and defined $method 0 48 48
Condition33%1/3
$invocant and defined $method
!ll&&!rl&&r
0048
MC/DC0%0/2
$invocant and defined $method
$invocant defined $method
Truth table33%1/3
A and B
A= $invocantB= defined $method
ABresult
0X0
100
111
1084 48 $invocant = _unwrap($invocant);
1085 48 ▶ return if $invocant->name ne 'padsv';
Branch: 1 branch
BranchTrueFalseTotal
if $invocant->name ne "padsv" 33 15 48
1086 15 ▶ my $var = $self->_padname( $invocant->targ ) // return;
Condition50%1/2
$self->_padname($invocant->targ) // (return)
l!l
150
MC/DC0%0/1
$self->_padname($invocant->targ) // (return)
$self->_padname($invocant->targ)
Truth table50%1/2
A
A= $self->_padname($invocant->targ)
Aresult
11
00
1087  
1088 15 my $usage = $self->_usage_of($var);
1089 15 ▶ $usage->{methods} //= [];
Condition50%1/2
$usage->{"methods"} //= []
l!l
015
MC/DC0%0/1
$usage->{"methods"} //= []
$usage->{"methods"}
Truth table50%1/2
A
A= $usage->{"methods"}
Aresult
11
00
1090 0 ▶ push @{ $usage->{methods} }, $method unless any { $_ eq $method } @{ $usage->{methods} };
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless &any(sub { $_ eq $method; } , @{$$usage{"methods"};}) 15 0 15
1091 15 return;
1092 }
1093  
1094 44 ▶sub _add_death {
Subroutine _add_death: called CC=2 SCAR=6.9
1095 44 my ( $self, $via, $ancestors ) = @_;
1096 44 ▶ push @{ $self->{rec}{dies} }, {
Branch: 1 branch
BranchTrueFalseTotal
_is_caught($ancestors) ? : 2 42 44
1097 via => $via,
1098 line => $self->{line},
1099 44 caught => _is_caught($ancestors) ? 1 : 0,
1100 };
1101 44 return;
1102 }
1103  
1104 # Inside eval {} or the try block of try/catch, but not inside its catch block.
1105 44 ▶sub _is_caught {
Subroutine _is_caught: called CC=6 SCAR=18.8
1106 44 my ($ancestors) = @_;
1107 44 foreach my $ancestor ( reverse @$ancestors ) {
1108 182 my $name = $ancestor->name;
1109 182 ▶ return 1 if $name eq 'leavetry';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "leavetry" 2 180 182
1110 180 ▶ return 0 if $name eq 'catch';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "catch" 0 180 180
1111 180 ▶ return 1 if $name eq 'leavetrycatch' || $name eq 'entertrycatch';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "leavetrycatch" or $name eq "entertrycatch" 0 180 180
Condition33%1/3
$name eq "leavetrycatch" or $name eq "entertrycatch"
l!l&&r!l&&!r
00180
MC/DC0%0/2
$name eq "leavetrycatch" or $name eq "entertrycatch"
$name eq "leavetrycatch" $name eq "entertrycatch"
Truth table33%1/3
A or B
A= $name eq "leavetrycatch"B= $name eq "entertrycatch"
ABresult
1X1
011
000
1112 }
1113 42 return 0;
1114 }
1115  
1116 27 ▶sub _on_die {
Subroutine _on_die: called CC=1 SCAR=0.0
1117 27 my ( $self, $op, $ancestors ) = @_;
1118 27 $self->_add_death( $op->name, $ancestors );
1119 27 return;
1120 }
1121  
1122 331 ▶sub _on_return {
Subroutine _on_return: called CC=4 SCAR=13.9
1123 331 my ( $self, $op ) = @_;
1124 331 my @values = _significant_kids($op);
1125 331 my $line = $self->{line};
1126 331 my @evidence;
1127 331 ▶ if ( !@values ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not @values) { } 89 242 331
elsif (@values == 1) { } 238 4 242
1128 89 @evidence = ( { type => 'empty' } );
1129 }
1130 elsif ( @values == 1 ) {
1131 238 @evidence = $self->classify( $values[0] );
1132 }
1133 else {
1134 4 my @items;
1135 4 foreach my $value (@values) {
1136 13 push @items, [ $self->classify($value) ];
1137 }
1138 4 @evidence = ( { type => 'list', count => scalar(@values), items => \@items } );
1139 }
1140 331 push @{ $self->{rec}{returns} }, map { +{ %$_, line => $line, implicit => 0 } } @evidence;
1141 331 return;
1142 }
1143  
1144 346 ▶sub _implicit_returns {
Subroutine _implicit_returns: called CC=2 SCAR=7.1
1145 346 my ( $self, $op ) = @_;
1146 346 ▶ $op = $op->first if $op->name eq 'leavesub';
Branch: 1 branch
BranchTrueFalseTotal
if $op->name eq "leavesub" 346 0 346
1147 346 return $self->_last_values($op);
1148 }
1149  
1150 0 ▶sub _classify_refgen {
Subroutine _classify_refgen: not called CC=8 SCAR=42.8
1151 0 my ( $self, $op ) = @_;
1152 0 my ($kid) = _significant_kids($op);
1153 0 ▶ $kid = _unwrap($kid) if $kid;
Branch: 1 branch
BranchTrueFalseTotal
if $kid 0 0 0
1154 0 ▶ my $kname = $kid ? $kid->name : '';
Branch: 1 branch
BranchTrueFalseTotal
$kid ? : 0 0 0
1155 0 ▶ return { type => 'coderef' } if $kname eq 'anoncode';
Branch: 1 branch
BranchTrueFalseTotal
if $kname eq "anoncode" 0 0 0
1156 0 ▶ return { type => 'arrayref' } if $kname eq 'padav' || $kname eq 'rv2av';
Branch: 1 branch
BranchTrueFalseTotal
if $kname eq "padav" or $kname eq "rv2av" 0 0 0
Condition0%0/3
$kname eq "padav" or $kname eq "rv2av"
l!l&&r!l&&!r
000
MC/DC0%0/2
$kname eq "padav" or $kname eq "rv2av"
$kname eq "padav" $kname eq "rv2av"
Truth table0%0/3
A or B
A= $kname eq "padav"B= $kname eq "rv2av"
ABresult
1X1
011
000
1157 0 ▶ return { type => 'hashref' } if $kname eq 'padhv' || $kname eq 'rv2hv';
Branch: 1 branch
BranchTrueFalseTotal
if $kname eq "padhv" or $kname eq "rv2hv" 0 0 0
Condition0%0/3
$kname eq "padhv" or $kname eq "rv2hv"
l!l&&r!l&&!r
000
MC/DC0%0/2
$kname eq "padhv" or $kname eq "rv2hv"
$kname eq "padhv" $kname eq "rv2hv"
Truth table0%0/3
A or B
A= $kname eq "padhv"B= $kname eq "rv2hv"
ABresult
1X1
011
000
1158 0 return { type => 'ref' };
1159 }
1160  
1161 21 ▶sub _classify_bless {
Subroutine _classify_bless: called CC=5 SCAR=16.2
1162 21 my ( $self, $op ) = @_;
1163 21 my ( undef, $class ) = _significant_kids($op);
1164 21 ▶ return { type => 'object', class => $self->{rec}{package} } if !$class;
Branch: 1 branch
BranchTrueFalseTotal
unless $class 3 18 21
1165 18 $class = _unwrap($class);
1166 18 ▶ return { type => 'object', class => _sv_value( $self->_const_sv($class) ) } if $class->name eq 'const';
Branch: 1 branch
BranchTrueFalseTotal
if $class->name eq "const" 10 8 18
1167  
1168 # bless REF, $class or bless REF, ref($proto) || $proto: the class comes from a variable.
1169 8 ▶ my $from = $class->name eq 'or' ? _unwrap( ( _kids($class) )[-1] ) : $class;
Branch: 1 branch
BranchTrueFalseTotal
$class->name eq 'or' ? : 2 6 8
1170 8 ▶ return { type => 'object', class => undef, class_from => $self->_padname( $from->targ ) } if $from->name eq 'padsv';
Branch: 1 branch
BranchTrueFalseTotal
if $from->name eq "padsv" 8 0 8
1171 0 return { type => 'object', class => undef };
1172 }
1173  
1174 19 1;
1175  
1176 __END__
« lib/Pod/Coverage/More/Analyzer/Perl5_36.pm ↑ Summary lib/Pod/Coverage/More/Types.pm »