JSON/Advance.pm

filter: Statementstmt 95.0% 38 / 40 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 93.2% 55 / 59 SCAR 16.1
CC
5
Cov
94%
err
4.1
__ANON__
2.0
BEGIN
1.0
CRAP 5.0
« JSON.pm ↑ Summary
1 package Error::Pure::JSON::Advance;
2  
3 # Pragmas.
4 6 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # Modules.
9 6 ▶use Error::Pure::Output::JSON qw(err_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 ▶use Error::Pure::Utils qw(err_helper);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use List::MoreUtils qw(none);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # Constants.
15 6 Readonly::Array our @EXPORT_OK => qw(err);
16 6 Readonly::Scalar my $EVAL => 'eval {...}';
17  
18 # Version.
19 6 our $VERSION = 0.06;
20  
21 # Global variables.
22 6 our %ERR_PARAMETERS;
23  
24 # Ignore die signal.
25 6 $SIG{__DIE__} = 'IGNORE';
26  
27 # Process error.
28 sub err {
29 7 ▶ my @msg = @_;
Subroutine err: called CC=4 SCAR=14.0
Pod documented
30  
31 # Get errors structure.
32 7 my @errors = err_helper(@msg);
33  
34 # Finalize in main on last err.
35 7 my $stack_ar = $errors[-1]->{'stack'};
36 7 ▶ if ($stack_ar->[-1]->{'class'} eq 'main'
Branch: 1 branch
BranchTrueFalseTotal
if ($stack_ar->[-1]{'class'} eq 'main' and &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{'sub'};} @{$stack_ar;}))) { } 2 5 7
Condition66%2/3
$stack_ar->[-1]{"class"} eq "main" and &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{"sub"};} @{$stack_ar;}))
!ll&&!rl&&r
052
MC/DC50%1/2
$stack_ar->[-1]{"class"} eq "main" and &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{"sub"};} @{$stack_ar;}))
$stack_ar->[-1]{"class"} eq "main" &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{"sub"};} @{$stack_ar;}))
Truth table66%2/3
A and B
A= $stack_ar->[-1]{"class"} eq "main"B= &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{"sub"};} @{$stack_ar;}))
ABresult
0X0
100
111
37 12 ▶ && none { $_ eq $EVAL || $_ =~ /^eval '/ms }
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_ eq $EVAL or $_ =~ /^eval '/ms 7 5 12
38 12 map { $_->{'sub'} } @{$stack_ar}) {
39  
40 2 my $err_hr = {
41 'error-pure' => \@errors,
42 };
43 2 foreach my $key (keys %ERR_PARAMETERS) {
44 0 $err_hr->{$key} = $ERR_PARAMETERS{$key};
45 }
46 2 die err_json($err_hr)."\n";
47  
48 # Die for eval.
49 } else {
50 5 die "$errors[-1]->{'msg'}->[0]\n";
51 }
52  
53 0 return;
54 }
55  
56 6 1;
57  
58 __END__
« JSON.pm ↑ Summary