JSON.pm

filter: Statementstmt 88.1% 37 / 42 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 82.5% 52 / 63 SCAR 16.4
CC
5
Cov
82%
err
4.7
__ANON__
2.0
BEGIN
1.0
CRAP 5.1
« JSON/Advance.pm ↑ Summary
1 package Error::Pure::HTTP::JSON;
2  
3 # Pragmas.
4 3 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # Modules.
9 3 ▶use Error::Pure::Output::JSON qw(err_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Error::Pure::Utils qw(err_helper);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use List::MoreUtils qw(none);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # Constants.
15 3 Readonly::Array our @EXPORT_OK => qw(err);
16 3 Readonly::Scalar my $EVAL => 'eval {...}';
17  
18 # Version.
19 3 our $VERSION = 0.05;
20  
21 # Ignore die signal.
22 3 $SIG{__DIE__} = 'IGNORE';
23  
24 # Process error.
25 sub err {
26 5 ▶ my @msg = @_;
Subroutine err: called CC=4 SCAR=15.6
Pod documented
27  
28 # Get errors structure.
29 5 my @errors = err_helper(@msg);
30  
31 # Finalize in main on last err.
32 5 my $stack_ar = $errors[-1]->{'stack'};
33 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
34 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
35 10 map { $_->{'sub'} } @{$stack_ar}) {
36  
37 0 print "Content-type: application/json\n\n";
38 0 print err_json(\@errors);
39 0 return;
40  
41 # Die for eval.
42 } else {
43 5 my $e = $errors[-1]->{'msg'}->[0];
44 5 ▶ if (! defined $e) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $e) { } 0 5 5
45 0 $e = 'undef';
46 } else {
47 5 chomp $e;
48 }
49 5 die "$e\n";
50 }
51  
52 0 return;
53 }
54  
55 3 1;
56  
57 __END__
« JSON/Advance.pm ↑ Summary