JSON/Advance.pm

filter: Statementstmt 82.6% 38 / 46 Branchbran 66.6% 4 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 79.1% 53 / 67 CC 6 SCAR 11.9
CC
6
Cov
78%
err
7.0
__ANON__
2.0
BEGIN
1.0
CRAP 3.3
↑ Summary JSON.pm »
1 package Error::Pure::HTTP::JSON::Advance;
2  
3 # Pragmas.
4 4 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # Modules.
9 4 ▶use Error::Pure::Output::JSON qw(err_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Error::Pure::Utils qw(err_helper);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use List::MoreUtils qw(none);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # Constants.
15 4 Readonly::Array our @EXPORT_OK => qw(err);
16 4 Readonly::Scalar my $EVAL => 'eval {...}';
17  
18 # Version.
19 4 our $VERSION = 0.04;
20  
21 # Global variables.
22 4 our %ERR_PARAMETERS;
23  
24 # Ignore die signal.
25 4 $SIG{__DIE__} = 'IGNORE';
26  
27 # Process error.
28 sub err {
29 5 ▶ my @msg = @_;
Subroutine err: called CC=5 SCAR=19.4
Pod documented
30  
31 # Get errors structure.
32 5 my @errors = err_helper(@msg);
33  
34 # Finalize in main on last err.
35 5 my $stack_ar = $errors[-1]->{'stack'};
36 5 ▶ 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;}))) { } 0 5 5
Condition33%1/3
$stack_ar->[-1]{"class"} eq "main" and &none(sub { $_ eq $EVAL or $_ =~ /^eval '/ms; } , map({$_->{"sub"};} @{$stack_ar;}))
!ll&&!rl&&r
050
MC/DC0%0/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 table33%1/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 10 ▶ && none { $_ eq $EVAL || $_ =~ /^eval '/ms }
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_ eq $EVAL or $_ =~ /^eval '/ms 5 5 10
38 10 map { $_->{'sub'} } @{$stack_ar}) {
39  
40 # Construct error structure.
41 0 my $err_hr = {
42 'error-pure' => \@errors,
43 };
44 0 foreach my $key (keys %ERR_PARAMETERS) {
45 0 $err_hr->{$key} = $ERR_PARAMETERS{$key};
46 }
47  
48 # Print out.
49 0 print "Content-type: application/json\n\n";
50 0 print err_json($err_hr);
51 0 return;
52  
53 # Die for eval.
54 } else {
55 5 my $e = $errors[-1]->{'msg'}->[0];
56 5 ▶ if (! defined $e) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $e) { } 0 5 5
57 0 $e = 'undef';
58 } else {
59 5 chomp $e;
60 }
61 5 die "$e\n";
62 }
63  
64 0 return;
65 }
66  
67 4 1;
68  
69 __END__
↑ Summary JSON.pm »