lib/CLI/Driver/Help.pm

filter: Statementstmt 95.5% 85 / 89 Branchbran 55.5% 20 / 36 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 17 / 17 Podpod n/a totaltotal 83.6% 123 / 147 CC 21 SCAR 19.9
CC
21
Cov
83%
parse
15.2
get_help
5.5
has_examples
4.2
CRAP 7.3
« lib/CLI/Driver/Method.pm ↑ Summary lib/CLI/Driver/Option.pm »
1 package CLI::Driver::Help;
2  
3 17 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶use Kavorka '-all';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 17 ▶use Data::Printer alias => 'pdump';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 17 with
10 'CLI::Driver::CommonRole';
11  
12 ###############################
13 ###### PUBLIC ATTRIBUTES ######
14 ###############################
15  
16 #has desc => ( is => 'rw' );
17  
18 has args => (
19 is => 'rw',
20 isa => 'HashRef[Str]',
21 240 ▶ default => sub { {} }
Subroutine __ANON__: called CC=1 SCAR=0.0
22 17 );
23  
24 has examples => (
25 is => 'rw',
26 isa => 'ArrayRef[Str]',
27 240 ▶ default => sub { [] }
Subroutine __ANON__: called CC=1 SCAR=0.0
28 17 );
29  
30 17 ▶method parse (HashRef|Undef :$href!) {
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine parse: called CC=14 SCAR=27.2
Branch: 8 branches
BranchTrueFalseTotal
@_ ? : 240 0 240
if ($#_ == 0 and ref $_[0] eq 'HASH') { } 0 240 240
if ($slice_length % 2 != 0) 0 240 240
if ($i <= $#_) 240 240 480
$OK{$_} or Carp::croak("Unknown named parameter: $_") 0 240 240
exists $_{'href'} ? : 240 0 240
if (exists $_{"href"}) 240 0 240
Type::Tiny::XS::AUTO::TC1($href) or _failed_check(45, "HashRef|Undef", $href, "exception_class", "Error::TypeTiny::Assertion") 0 240 240
Condition33%1/3
$#_ == 0 and ref $_[0] eq "HASH"
!ll&&!rl&&r
24000
MC/DC0%0/2
$#_ == 0 and ref $_[0] eq "HASH"
$#_ == 0 ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= $#_ == 0B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
31
32 # Don't fail if no help provided.
33 240 ▶ return 1 if !defined $href;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $href 224 16 240
34  
35 # self->args
36 16 ▶ if( exists $href->{args} ){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $href->{"args"}) 16 0 16
37 16 $self->args( { %{$href->{args}} } );
38 }
39
40 # self->examples
41 16 ▶ if( exists $href->{examples} ){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $href->{"examples"}) 16 0 16
42 16 $self->examples( [ @{$href->{examples}} ] );
43 }
44  
45 16 return 1; # success
46 }
47  
48 17 ▶method get_help( $arg ) {
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine get_help: called CC=5 SCAR=17.0
Branch: 3 branches
BranchTrueFalseTotal
@_ ? : 5 0 5
if @_ != 1 0 5 5
$#_ >= 0 ? : 5 0 5
49  
50 5 ▶ if( exists $self->args->{$arg} ){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->args->{$arg}) 5 0 5
51 5 return $self->args->{$arg};
52 }
53  
54 0 return "";
55 }
56  
57 17 ▶method has_examples(){
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine has_examples: called CC=4 SCAR=14.4
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 1 0 1
if @_ != 0 0 1 1
58 1 ▶ if( @{$self->examples} ){
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->examples;}) 1 0 1
59 1 return 1;
60 }
61
62 0 return 0;
63 }
64  
65 17 1;
« lib/CLI/Driver/Method.pm ↑ Summary lib/CLI/Driver/Option.pm »