Catmandu/Fix/error.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 100% 48 / 48 CC 3 SCAR 3.1
CC
3
Cov
100%
_build_fixer
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.4
« Catmandu/Fix/Condition/Builder.pm ↑ Summary Catmandu/Fix/Namespace/perl.pm »
1 package Catmandu::Fix::error;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '1.2025';
6  
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Catmandu::Util qw(is_value);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Catmandu::Util::Path qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 with 'Catmandu::Fix::Builder';
14  
15 1 has message => (fix_arg => 1);
16  
17 4 ▶sub _build_fixer {
Subroutine _build_fixer: called CC=2 SCAR=6.9
18 4 my ($self) = @_;
19 4 my $msg = $self->message;
20 4 ▶ if (looks_like_path($msg)) {
Branch: 1 branch
BranchTrueFalseTotal
if (looks_like_path($msg)) { } 3 1 4
21 3 my $getter = as_path($msg)->getter;
22 3 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
23 3 my $data = $_[0];
24 3 my $vals = $getter->($data);
25 3 ▶ @$vals || return $data;
Branch: 1 branch
BranchTrueFalseTotal
@$vals or return $data 2 1 3
26 2 my $str = join "\n", grep {is_value($_)} @$vals;
27 2 Catmandu::Error->throw($str);
28 3 };
29 }
30 else {
31 1 ▶ sub {Catmandu::Error->throw($msg)};
Subroutine __ANON__: called CC=1 SCAR=0.0
32 }
33  
34 }
35  
36 1 1;
37  
38 __END__
« Catmandu/Fix/Condition/Builder.pm ↑ Summary Catmandu/Fix/Namespace/perl.pm »