Respite/Common.pm

filter: Statementstmt 89.6% 26 / 29 Branchbran 100% 4 / 4 Conditioncond 65.5% 19 / 29 MC/DCmcdc 28.5% 4 / 14 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 3 totaltotal 68.2% 58 / 85 CC 14 SCAR 19.5
CC
14
Cov
79%
jsop
12.0
_configs
9.1
json
3.1
CRAP 7.0
« Respite/Server/Test.pm ↑ Summary Respite.pm »
1 package Net::Respite::Common;
2  
3 =pod
4  
5 =head1 NAME
6  
7 Net::Respite::Common - Common methods used internally
8  
9 =head1 SYNOPSIS
10  
11 package CustomModule;
12 use base 'Net::Respite::Common';
13  
14 sub xkey1 { return shift->_configs->{xxx_key} || "unknown" }
15  
16 sub parse1 { return shift->json->decode(shift) }
17  
18 =cut
19  
20 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 27 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
24 27 my ($class, $args) = @_;
25 27 ▶ return bless {%{$args || {}}}, $class;
Condition100%2/2
$args || {}
l!l
198
MC/DC100%1/1
$args || {}
$args
Truth table100%2/2
A
A= $args
Aresult
11
00
26 }
27  
28 11 our $js;
29 27 ▶sub json { $js ||= eval { require JSON; JSON->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical } || die "Could not load JSON: $@" }
Subroutine json: called CC=3 SCAR=11.4
Pod undocumented
Condition60%3/5
$Net::Respite::Common::js ||= eval { do { require JSON; "JSON"->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical } } || die("Could not load JSON: $@")
l!l&&r!l&&!r
17100
eval { do { require JSON; 'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical } } || die("Could not load JSON: $@")
l!l
100
MC/DC0%0/2
$Net::Respite::Common::js ||= eval { do { require JSON; "JSON"->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical } } || die("Could not load JSON: $@")
$Net::Respite::Common::js eval { do { require JSON; 'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical } }
Truth table66%2/3
A ||= B
A= $Net::Respite::Common::jsB= eval { do { require JSON; 'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical } }
ABresult
1X1
011
000
30 11 our $jp;
31 0 ▶sub jsop { $jp ||= eval { require JSON; JSON->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty } || die "Could not load JSON: $@" }
Subroutine jsop: not called CC=3 SCAR=24.8
Pod undocumented
Condition0%0/5
$Net::Respite::Common::jp ||= eval { do { require JSON; "JSON"->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty } } || die("Could not load JSON: $@")
l!l&&r!l&&!r
000
eval { do { require JSON; 'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty } } || die("Could not load JSON: $@")
l!l
00
MC/DC0%0/2
$Net::Respite::Common::jp ||= eval { do { require JSON; "JSON"->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty } } || die("Could not load JSON: $@")
$Net::Respite::Common::jp eval { do { require JSON; 'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty } }
Truth table0%0/3
A ||= B
A= $Net::Respite::Common::jpB= eval { do { require JSON; 'JSON'->new->utf8->allow_unknown->allow_nonref->convert_blessed->canonical->pretty } }
ABresult
1X1
011
000
32  
33 11 our $config;
34 182 ▶sub _configs {
Subroutine _configs: called CC=9 SCAR=22.1
35 182 ▶ return $config ||= do {
Condition66%2/3
$Net::Respite::Common::config ||= do { my $c = undef; eval { do { require config; eval { do { $c = "config"->load } }; $c ||= defined $config::config && "HASH" eq ref $config::config && $config::config; $c ||= %config::config ? \%config::config : undef } }; "HASH" eq ref $c or $c = {"failed_load", $@ || "missing config::config hash"}; $c }
l!l&&r!l&&!r
17480
MC/DC0%0/2
$Net::Respite::Common::config ||= do { my $c = undef; eval { do { require config; eval { do { $c = "config"->load } }; $c ||= defined $config::config && "HASH" eq ref $config::config && $config::config; $c ||= %config::config ? \%config::config : undef } }; "HASH" eq ref $c or $c = {"failed_load", $@ || "missing config::config hash"}; $c }
$Net::Respite::Common::config do { my $c = undef; eval { do { require config; eval { do { $c = "config"->load } }; $c ||= defined $config::config && "HASH" eq ref $config::config && $config::config; $c ||= %config::config ? \%config::config : undef } }; "HASH" eq ref $c or $c = {"failed_load", $@ || "missing config::config hash"}; $c }
Truth table66%2/3
A ||= B
A= $Net::Respite::Common::configB= do { my $c = undef; eval { do { require config; eval { do { $c = "config"->load } }; $c ||= defined $config::config && "HASH" eq ref $config::config && $config::config; $c ||= %config::config ? \%config::config : undef } }; "HASH" eq ref $c or $c = {"failed_load", $@ || "missing config::config hash"}; $c }
ABresult
1X1
011
000
36 8 my $c = undef;
37 8 eval {
38 8 require config;
39 7 eval { $c = config->load };
40 7 ▶ $c ||= defined($config::config) && "HASH" eq ref $config::config && $config::config;
Condition77%7/9
$c ||= defined $config::config && "HASH" eq ref $config::config && $config::config
l!l&&r!l&&!r
412
defined $config::config && 'HASH' eq ref $config::config && $config::config
!ll&&!rl&&r
201
defined $config::config and "HASH" eq ref $config::config
!ll&&!rl&&r
201
MC/DC0%0/4
$c ||= defined $config::config && "HASH" eq ref $config::config && $config::config
$c defined $config::config "HASH" eq ref $config::config $config::config
Truth table0%0/5
A ||= B and C && D
A= $cB= defined $config::configC= "HASH" eq ref $config::configD= $config::config
ABCDresult
1XXX1
01111
00XX0
010X0
01100
41 7 ▶ $c ||= %config::config ? \%config::config : undef;
Branch: 1 branch
BranchTrueFalseTotal
%config::config ? : 1 1 2
Condition100%3/3
$c ||= %config::config ? \%config::config : undef
l!l&&r!l&&!r
511
MC/DC100%2/2
$c ||= %config::config ? \%config::config : undef
$c %config::config ? \%config::config : undef
Truth table100%3/3
A ||= B
A= $cB= %config::config ? \%config::config : undef
ABresult
1X1
011
000
42 };
43 8 ▶ "HASH" eq ref $c or $c = { failed_load => ($@ || "missing config::config hash") };
Branch: 1 branch
BranchTrueFalseTotal
"HASH" eq ref $c or $c = {"failed_load", $@ || "missing config::config hash"} 6 2 8
Condition100%2/2
$@ || 'missing config::config hash'
l!l
11
MC/DC100%1/1
$@ || 'missing config::config hash'
$@
Truth table100%2/2
A
A= $@
Aresult
11
00
44 8 $c;
45 };
46 }
47  
48 11 1;
« Respite/Server/Test.pm ↑ Summary Respite.pm »