JSON.pm

filter: Statementstmt 95.0% 38 / 40 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 91.8% 56 / 61 SCAR 16.1
CC
5
Cov
92%
err
4.1
__ANON__
2.0
BEGIN
1.0
CRAP 5.0
↑ Summary JSON/Advance.pm »
1 package Error::Pure::JSON;
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 # Ignore die signal.
22 6 $SIG{__DIE__} = 'IGNORE';
23  
24 # Process error.
25 sub err {
26 7 ▶ my @msg = @_;
Subroutine err: called CC=4 SCAR=14.1
Pod documented
27  
28 # Get errors structure.
29 7 my @errors = err_helper(@msg);
30  
31 # Finalize in main on last err.
32 7 my $stack_ar = $errors[-1]->{'stack'};
33 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
34 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
35 12 map { $_->{'sub'} } @{$stack_ar}) {
36  
37 2 die err_json(\@errors)."\n";
38  
39 # Die for eval.
40 } else {
41 5 my $e = $errors[-1]->{'msg'}->[0];
42 5 ▶ if (! defined $e) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $e) { } 0 5 5
43 0 $e = 'undef';
44 } else {
45 5 chomp $e;
46 }
47 5 die "$e\n";
48 }
49  
50 0 return;
51 }
52  
53 6 1;
54  
55 __END__
↑ Summary JSON/Advance.pm »