Yath/Option/List.pm

filter: Statementstmt 81.8% 63 / 77 Branchbran 38.8% 7 / 18 Conditioncond 42.8% 3 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 95.2% 20 / 21 Podpod 0.0% 0 / 16 totaltotal 65.0% 93 / 143 CC 14 SCAR 13.4
CC
14
Cov
72%
get_initial_value
9.5
normalize_value
7.3
add_value
3.2
CRAP 3.8
« Yath/Option/Map.pm ↑ Summary Yath/Option/Auto.pm »
1 package Getopt::Yath::Option::List;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '2.000007';
6  
7 1 ▶use Getopt::Yath::Util qw/decode_json/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use parent 'Getopt::Yath::Option';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Getopt::Yath::HashBase qw/<split_on/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 8 ▶sub allows_list { 1 }
Subroutine allows_list: called CC=1 SCAR=0.0
Pod undocumented
13 8 ▶sub allows_arg { 1 }
Subroutine allows_arg: called CC=1 SCAR=0.0
Pod undocumented
14 8 ▶sub requires_arg { 1 }
Subroutine requires_arg: called CC=1 SCAR=0.0
Pod undocumented
15 2 ▶sub allows_default { 1 }
Subroutine allows_default: called CC=1 SCAR=0.0
Pod undocumented
16 0 ▶sub allows_autofill { 0 }
Subroutine allows_autofill: not called CC=1 SCAR=6.9
Pod undocumented
17 1 ▶sub requires_autofill { 0 }
Subroutine requires_autofill: called CC=1 SCAR=0.0
Pod undocumented
18  
19 4 ▶sub notes { (shift->SUPER::notes(), 'Can be specified multiple times') }
Subroutine notes: called CC=1 SCAR=0.0
Pod undocumented
20  
21 28 ▶sub is_populated { ${$_[1]} && @{${$_[1]}} }
Subroutine is_populated: called CC=2 SCAR=7.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
${$_[1];} and @{${$_[1];};} 28 0 28
22  
23 sub get_clear_value {
24 2 ▶ my $self = shift;
Subroutine get_clear_value: called CC=2 SCAR=7.2
Pod undocumented
25 2 ▶ return $self->_get___value(CLEAR(), @_) // [];
Condition50%1/2
$self->_get___value("clear", @_) // []
l!l
02
MC/DC0%0/1
$self->_get___value("clear", @_) // []
$self->_get___value("clear", @_)
Truth table50%1/2
A
A= $self->_get___value("clear", @_)
Aresult
11
00
26 }
27  
28 sub get_initial_value {
29 32 ▶ my $self = shift;
Subroutine get_initial_value: called CC=7 SCAR=22.5
Pod undocumented
30  
31 32 my @val;
32  
33 32 my $env = $self->from_env_vars;
34 32 ▶ for my $name (@{$env || []}) {
Branch: 1 branch
BranchTrueFalseTotal
$env or [] 32 0 32
35 0 ▶ push @val => $ENV{$name} if defined $ENV{$name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ENV{$name} 0 0 0
36 }
37  
38 32 ▶ return \@val if @val;
Branch: 1 branch
BranchTrueFalseTotal
if @val 0 32 32
39  
40 32 ▶ return undef if $self->{+MAYBE};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"maybe"} 0 32 32
41 32 ▶ return $self->_get___value(INITIALIZE()) // [];
Condition50%1/2
$self->_get___value("initialize") // []
l!l
032
MC/DC0%0/1
$self->_get___value("initialize") // []
$self->_get___value("initialize")
Truth table50%1/2
A
A= $self->_get___value("initialize")
Aresult
11
00
42 }
43  
44 sub add_value {
45 64 ▶ my $self = shift;
Subroutine add_value: called CC=3 SCAR=11.8
Pod undocumented
46 64 my ($ref, @val) = @_;
47 64 ▶ return if $self->maybe && !@val;
Branch: 1 branch
BranchTrueFalseTotal
if $self->maybe and not @val 0 64 64
Condition33%1/3
$self->maybe and not @val
!ll&&!rl&&r
6400
MC/DC0%0/2
$self->maybe and not @val
$self->maybe not @val
Truth table33%1/3
A and not(B)
A= $self->maybeB= not @val
ABresult
0X0
100
111
48 64 push @{$$ref} => @val;
49 }
50  
51 sub normalize_value {
52 7 ▶ my $self = shift;
Subroutine normalize_value: called CC=4 SCAR=19.9
Pod undocumented
53 7 my (@input) = @_;
54  
55 7 ▶ if ($input[0] =~ m/^\s*\[.*\]\s*$/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input[0] =~ /^\s*\[.*\]\s*$/s) 0 7 7
56 0 my $out;
57 0 local $@;
58 0 ▶ unless (eval { local $SIG{__DIE__}; $out = decode_json($input[0]); 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { local $SIG{"__DIE__"}; $out = decode_json($input[0]); 1 } }) 0 0 0
59 0 my ($err) = split /[\n\r]+/, $@;
60 0 $err =~ s{at \Q$INC{'Getopt/Yath/Util/JSON.pm'}\E line \d+\..*$}{};
61 0 die "Could not decode JSON string: $err\n====\n$input[0]\n====\n";
62 }
63 0 return @$out;
64 }
65  
66 7 my @output;
67 7 ▶ if (my $on = $self->split_on) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $on = $self->split_on) { } 7 0 7
68 7 @output = map { $self->SUPER::normalize_value($_) } map { split($on, $_) } @input;
69 }
70 else {
71 0 @output = map { $self->SUPER::normalize_value($_) } @input;
72 }
73  
74 7 return @output;
75 }
76  
77 2 ▶sub inject_default_long_examples { qq{ '["json","list"]'}, qq{='["json","list"]'} }
Subroutine inject_default_long_examples: called CC=1 SCAR=0.0
Pod undocumented
78 2 ▶sub inject_default_short_examples { qq{ '["json","list"]'}, qq{='["json","list"]'} }
Subroutine inject_default_short_examples: called CC=1 SCAR=0.0
Pod undocumented
79  
80 sub default_long_examples {
81 4 ▶ my $self = shift;
Subroutine default_long_examples: called CC=1 SCAR=0.0
Pod undocumented
82 4 my %params = @_;
83  
84 4 my $list = $self->SUPER::default_long_examples(%params);
85 4 push @$list => $self->inject_default_long_examples();
86 4 return $list;
87 }
88  
89 sub default_short_examples {
90 4 ▶ my $self = shift;
Subroutine default_short_examples: called CC=1 SCAR=0.0
Pod undocumented
91 4 my %params = @_;
92  
93 4 my $list = $self->SUPER::default_long_examples(%params);
94 4 push @$list => $self->inject_default_short_examples();
95 4 return $list;
96 }
97  
98  
99 1 1;
100  
101 __END__
« Yath/Option/Map.pm ↑ Summary Yath/Option/Auto.pm »