Catmandu/Fix/Condition/SimpleAllTest.pm

filter: Statementstmt 32.5% 14 / 43 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 1 totaltotal 30.9% 17 / 55 CC 3 SCAR 12.4
CC
3
Cov
30%
emit
6.0
__ANON__
6.0
__ANON__
2.0
CRAP 3.4
« Catmandu/Store/Multi/Bag.pm ↑ Summary Catmandu/Fix/Inlineable.pm »
1 package Catmandu::Fix::Condition::SimpleAllTest;
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::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 with 'Catmandu::Fix::Condition';
11  
12 1 requires 'path';
13 1 requires 'emit_test';
14  
15 0 ▶sub emit {
Subroutine emit: not called CC=2 SCAR=17.9
Pod undocumented
16 0 my ($self, $fixer, $label) = @_;
17 0 my $path = $fixer->split_path($self->path);
18 0 my $key = pop @$path;
19  
20 0 my $pass_fixes = $self->pass_fixes;
21 0 my $fail_fixes = $self->fail_fixes;
22  
23 0 my $fail_label;
24 my $fail_block = $fixer->emit_block(
25 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 $fail_label = shift;
27  
28 0 $fixer->emit_fixes($fail_fixes);
29 }
30 0 );
31  
32 0 my $has_match_var = $fixer->generate_var;
33  
34 0 my $perl = $fixer->emit_declare_vars($has_match_var, '0');
35  
36 $perl .= $fixer->emit_walk_path(
37 $fixer->var,
38 $path,
39 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 0 my $var = shift;
41 $fixer->emit_get_key(
42 $var, $key,
43 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
44 0 my $var = shift;
45 0 my $perl = "${has_match_var} ||= 1;";
46 0 $perl .= "unless ("
47 . $self->emit_test($var, $fixer) . ") {";
48 0 ▶ if (@$fail_fixes) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$fail_fixes) { } 0 0 0
49 0 $perl .= "goto ${fail_label};";
50 }
51 else {
52 0 $perl .= "last ${label};";
53 }
54 0 $perl .= "}";
55 0 $perl;
56 }
57 0 );
58 }
59 0 );
60  
61 0 $perl .= "if (${has_match_var}) {";
62  
63 0 $perl .= $fixer->emit_fixes($pass_fixes);
64  
65 0 $perl .= "last ${label};";
66 0 $perl .= "}";
67  
68 0 ▶ if (@$fail_fixes) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$fail_fixes) 0 0 0
69 0 $perl .= $fail_block;
70 }
71  
72 0 $perl;
73 }
74  
75 1 1;
76  
77 __END__
« Catmandu/Store/Multi/Bag.pm ↑ Summary Catmandu/Fix/Inlineable.pm »