Catmandu/Fix/Inlineable.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 66.6% 4 / 6 Conditioncond 37.5% 3 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 78.6% 48 / 61 CC 7 SCAR 12.4
CC
7
Cov
84%
__ANON__
6.1
import
3.1
BEGIN
1.0
CRAP 3.4
« Catmandu/Fix/Condition/SimpleAllTest.pm ↑ Summary Catmandu/Store.pm »
1 package Catmandu::Fix::Inlineable;
2  
3 115 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 115 our $VERSION = '1.2025';
6  
7 115 ▶use Clone qw(clone);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 115 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 115 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 115 requires 'fix';
12  
13 99 ▶sub import {
Subroutine import: called CC=3 SCAR=11.4
14 99 my $target = caller;
15 99 my ($pkg, %opts) = @_;
16  
17 99 ▶ if (my $sym = $opts{as}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sym = $opts{"as"}) 2 97 99
18 2 ▶ $opts{cache} //= 1;
Condition50%1/2
$opts{"cache"} //= 1
l!l
02
MC/DC0%0/1
$opts{"cache"} //= 1
$opts{"cache"}
Truth table50%1/2
A
A= $opts{"cache"}
Aresult
11
00
19  
20 2 ▶ my $sub = sub {
Subroutine __ANON__: called CC=5 SCAR=18.0
21 2 my $data = shift;
22 2 my $fixer;
23  
24 2 state $cache = {};
25 2 ▶ if ($opts{cache}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"cache"}) 2 0 2
26 2 my $key = join('--', @_);
27 2 ▶ $fixer = $cache->{$key} ||= $pkg->new(@_);
Condition33%1/3
$cache->{$key} ||= $pkg->new(@_)
l!l&&r!l&&!r
020
MC/DC0%0/2
$cache->{$key} ||= $pkg->new(@_)
$cache->{$key} $pkg->new(@_)
Truth table33%1/3
A ||= B
A= $cache->{$key}B= $pkg->new(@_)
ABresult
1X1
011
000
28 }
29  
30 2 ▶ $fixer ||= $pkg->new(@_);
Condition33%1/3
$fixer ||= $pkg->new(@_)
l!l&&r!l&&!r
200
MC/DC0%0/2
$fixer ||= $pkg->new(@_)
$fixer $pkg->new(@_)
Truth table33%1/3
A ||= B
A= $fixerB= $pkg->new(@_)
ABresult
1X1
011
000
31  
32 2 ▶ if ($opts{clone}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"clone"}) 0 2 2
33 0 $data = clone($data);
34 }
35  
36 2 $fixer->fix($data);
37 2 };
38 115 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
39 2 *{"${target}::$sym"} = $sub;
40 }
41 }
42  
43 115 1;
44  
45 __END__
« Catmandu/Fix/Condition/SimpleAllTest.pm ↑ Summary Catmandu/Store.pm »