Data/Printer/Filter/CODE.pm

filter: Statementstmt 89.1% 41 / 46 Branchbran 66.6% 4 / 6 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 74.0% 57 / 77 CC 7 SCAR 14.4
CC
7
Cov
79%
parse
8.6
_subref_is_reachable
2.2
BEGIN
1.0
CRAP 4.2
« Data/Printer/Filter/Digest.pm ↑ Summary Data/Printer/Filter/Regexp.pm »
1 package Data::Printer::Filter::CODE;
2 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 35 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 35 ▶use Data::Printer::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 35 ▶use Data::Printer::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 35 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 35 ▶use Fcntl;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 35 filter 'CODE' => \&parse;
10  
11  
12 6 ▶sub parse {
Subroutine parse: called CC=6 SCAR=21.5
Pod undocumented
13 6 my ($subref, $ddp) = @_;
14 6 my $string;
15 6 my $color = 'code';
16 6 ▶ if ($ddp->deparse) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ddp->deparse) { } 2 4 6
elsif ($ddp->coderef_undefined and not _subref_is_reachable($subref)) { } 0 4 4
17 2 $string = _deparse($subref, $ddp);
18 2 ▶ if ($ddp->coderef_undefined && $string =~ /\A\s*sub\s*;\s*\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ddp->coderef_undefined and $string =~ /\A\s*sub\s*;\s*\z/) 0 2 2
Condition33%1/3
$ddp->coderef_undefined and $string =~ /\A\s*sub\s*;\s*\z/
!ll&&!rl&&r
020
MC/DC0%0/2
$ddp->coderef_undefined and $string =~ /\A\s*sub\s*;\s*\z/
$ddp->coderef_undefined $string =~ /\A\s*sub\s*;\s*\z/
Truth table33%1/3
A and B
A= $ddp->coderef_undefinedB= $string =~ /\A\s*sub\s*;\s*\z/
ABresult
0X0
100
111
19 0 $string = $ddp->coderef_undefined;
20 0 $color = 'undef';
21 }
22 }
23 ▶ elsif ($ddp->coderef_undefined && !_subref_is_reachable($subref)) {
Condition33%1/3
$ddp->coderef_undefined and not _subref_is_reachable($subref)
!ll&&!rl&&r
040
MC/DC0%0/2
$ddp->coderef_undefined and not _subref_is_reachable($subref)
$ddp->coderef_undefined not _subref_is_reachable($subref)
Truth table33%1/3
A and not(B)
A= $ddp->coderef_undefinedB= not _subref_is_reachable($subref)
ABresult
0X0
100
111
24 0 $string = $ddp->coderef_undefined;
25 0 $color = 'undef';
26 }
27 else {
28 4 $string = $ddp->coderef_stub;
29 }
30 6 return $ddp->maybe_colorize($string, $color);
31 };
32  
33 #######################################
34 ### Private auxiliary helpers below ###
35 #######################################
36  
37 2 ▶sub _deparse {
Subroutine _deparse: called CC=1 SCAR=0.0
38 2 my ($subref, $ddp) = @_;
39 2 require B::Deparse;
40  
41 # FIXME: line below breaks encapsulation on Data::Printer::Object
42 2 my $i = $ddp->{indent} + $ddp->{_array_padding};
43  
44 2 my $deparseopts = ["-sCi${i}v'Useless const omitted'"];
45  
46 2 my $sub = 'sub ' . B::Deparse->new($deparseopts)->coderef2text($subref);
47 2 my $pad = $ddp->newline;
48 2 $sub =~ s/\n/$pad/gse;
49 2 return $sub;
50 }
51  
52 4 ▶sub _subref_is_reachable {
Subroutine _subref_is_reachable: called CC=2 SCAR=7.9
53 4 my ($subref) = @_;
54 4 require B;
55 4 my $cv = B::svref_2object($subref);
56 0 ▶ return !(B::class($cv->ROOT) eq 'NULL' && !${ $cv->const_sv });
Condition33%1/3
B::class($cv->ROOT) eq 'NULL' && !${$cv->const_sv;}
!ll&&!rl&&r
400
MC/DC0%0/2
B::class($cv->ROOT) eq 'NULL' && !${$cv->const_sv;}
B::class($cv->ROOT) eq 'NULL' !${$cv->const_sv;}
Truth table33%1/3
A && not(B)
A= B::class($cv->ROOT) eq 'NULL'B= !${$cv->const_sv;}
ABresult
0X0
100
111
57 }
58  
59 35 1;
« Data/Printer/Filter/Digest.pm ↑ Summary Data/Printer/Filter/Regexp.pm »