Modern/Error.pm

filter: Statementstmt 98.7% 80 / 81 Branchbran 75.0% 6 / 8 Conditioncond 50.0% 5 / 10 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 96.3% 26 / 27 Podpod 50.0% 1 / 2 totaltotal 89.4% 119 / 133 CC 9 SCAR 10.7
CC
9
Cov
92%
__ANON__
9.9
__ANON__
2.0
stringify
2.0
CRAP 2.9
« Modern/Vocabulary/Content.pm ↑ Summary Modern/Vocabulary.pm »
1 46 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 46 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package JSON::Schema::Modern::Error;
4 # vim: set ts=8 sts=2 sw=2 tw=100 et :
5 # ABSTRACT: Contains a single error from a JSON Schema evaluation
6  
7 46 our $VERSION = '0.654';
8  
9 46 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 46 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 46 with 'JSON::Schema::Modern::ResultNode';
12 46 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 46 ▶use stable 0.031 'postderef';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 46 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 46 ▶no autovivification warn => qw(fetch store exists delete);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 46 ▶use if "$]" >= 5.022, experimental => 're_strict';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 46 ▶no if "$]" >= 5.031009, feature => 'indirect';
Subroutine BEGIN: called CC=1 SCAR=0.0
18 46 ▶no if "$]" >= 5.033001, feature => 'multidimensional';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 46 ▶no if "$]" >= 5.033006, feature => 'bareword_filehandles';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 46 ▶no if "$]" >= 5.041009, feature => 'smartmatch';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 46 ▶no feature 'switch';
Subroutine BEGIN: called CC=1 SCAR=0.0
22 46 ▶use MooX::TypeTiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 46 ▶use Types::Standard qw(Str Bool Enum Tuple);
Subroutine BEGIN: called CC=1 SCAR=0.0
24 46 ▶use Types::Common::Numeric qw(PositiveInt);
Subroutine BEGIN: called CC=1 SCAR=0.0
25 46 ▶use builtin::compat 'refaddr';
Subroutine BEGIN: called CC=1 SCAR=0.0
26 46 ▶use Mojo::Message::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 46 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
28 46 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 use overload
31 0 ▶ '""' => sub { $_[0]->stringify },
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 46 fallback => 1;
33  
34 46 has error => (
35 is => 'ro',
36 isa => Str,
37 required => 1,
38 );
39  
40 46 has exception => (
41 is => 'ro',
42 isa => Bool,
43 );
44  
45 46 has mode => (
46 is => 'ro',
47 isa => Enum[qw(traverse evaluate)],
48 required => 1,
49 );
50  
51 46 has recommended_response => (
52 is => 'ro',
53 isa => Tuple[PositiveInt, Str],
54 );
55  
56 7 ▶sub stringify ($self) {
Subroutine stringify: called CC=2 SCAR=6.9
Pod undocumented
57 7 ▶ $self->mode eq 'traverse'
Branch: 1 branch
BranchTrueFalseTotal
$self->mode eq 'traverse' ? : 3 4 7
58 ? '\''.$self->keyword_location.'\': '.$self->error
59 : '\''.$self->instance_location.'\': '.$self->error;
60 }
61  
62 2 ▶sub clone ($self, %overrides) {
Subroutine clone: called CC=2 SCAR=6.9
Pod documented
63 $self->new(
64 $self->%{qw(instance_location keyword_location keyword depth)},
65 (map +(exists $self->{$_} ? $self->%{$_} : ()), qw(absolute_keyword_location _uri recommended_response)),
66 2 ▶ $self->%{qw(error exception mode)},
Branch: 1 branch
BranchTrueFalseTotal
exists $$self{$_} ? : 2 4 6
67 %overrides,
68 );
69 }
70  
71 18784 ▶sub __thing { 'error' }
Subroutine __thing: called CC=1 SCAR=0.0
72  
73 14126 ▶around BUILDARGS => sub ($orig, $class, @args) {
Subroutine __ANON__: called CC=7 SCAR=22.9
74 14126 my $args = $class->$orig(@args);
75  
76 $args->{recommended_response}[1] =
77 Mojo::Message::Response->default_message($args->{recommended_response}[0]) // 'Unknown Error'
78 14126 ▶ if $args->{recommended_response} and $args->{recommended_response}->@* == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $$args{"recommended_response"} and @{$$args{"recommended_response"}} == 1 0 14126 14126
Condition40%2/5
$$args{"recommended_response"} and @{$$args{"recommended_response"}} == 1
!ll&&!rl&&r
1412420
"Mojo::Message::Response"->default_message($$args{"recommended_response"}[0]) // "Unknown Error"
l!l
00
MC/DC0%0/2
$$args{"recommended_response"} and @{$$args{"recommended_response"}} == 1
$$args{"recommended_response"} @{$$args{"recommended_response"}} == 1
MC/DC0%0/1
"Mojo::Message::Response"->default_message($$args{"recommended_response"}[0]) // "Unknown Error"
"Mojo::Message::Response"->default_message($$args{"recommended_response"}[0])
Truth table66%2/3
A and B
A= $$args{"recommended_response"}B= @{$$args{"recommended_response"}} == 1
ABresult
0X0
100
111
Truth table0%0/2
A
A= "Mojo::Message::Response"->default_message($$args{"recommended_response"}[0])
Aresult
11
00
79  
80 croak 'instance_location must be defined when mode=evaluate'
81 14126 ▶ if not defined $args->{instance_location} and ($args->{mode}//'') eq 'evaluate';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $$args{"instance_location"} and ($$args{"mode"} // "") eq "evaluate" 0 14126 14126
Condition60%3/5
not defined $$args{"instance_location"} and ($$args{"mode"} // "") eq "evaluate"
!ll&&!rl&&r
138952310
$$args{"mode"} // ""
l!l
2310
MC/DC50%1/2
not defined $$args{"instance_location"} and ($$args{"mode"} // "") eq "evaluate"
not defined $$args{"instance_location"} $$args{"mode"}
Truth table66%2/3
not(A) and B
A= not defined $$args{"instance_location"}B= $$args{"mode"}
ABresult
0X0
100
111
82  
83 14126 return $args;
84 46 };
85  
86 46 1;
87  
88 __END__
« Modern/Vocabulary/Content.pm ↑ Summary Modern/Vocabulary.pm »