lib/FindApp/Object/Behavior/Shortcuts.pm

filter: Statementstmt 80.0% 96 / 120 Branchbran 71.4% 20 / 28 Conditioncond 55.5% 10 / 18 MC/DCmcdc 20.0% 2 / 10 Subroutinesub 63.6% 14 / 22 Podpod n/a totaltotal 71.7% 142 / 198 CC 38 SCAR 8.8
CC
38
Cov
76%
add_bindirs_allowed
3.3
add_bindirs_found
3.3
add_libdirs_allowed
3.3
CRAP 2.4
« blib/lib/FindApp/Utils/Package.pm ↑ Summary lib/FindApp/Utils/Paths.pm »
1 package FindApp::Object::Behavior::Shortcuts;
2  
3 6 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use mro "c3";
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use FindApp::Vars qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use FindApp::Utils qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 my @_SUBDIRS = +BLM;
14 1 my @_ALLDIRS = (root => @_SUBDIRS);
15  
16 1 for my $DIR (@_ALLDIRS) {
17 # BUILD: export_bin_to_env
18 # BUIOD: export_lib_to_env
19 # BUIOD: export_man_to_env
20 # BUIOD: export_root_to_env
21 0 ▶ function "export_${DIR}_to_env" => sub { &ENTER_TRACE;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Subroutine export_root_to_env: called CC=1 SCAR=0.4
Subroutine export_man_to_env: called CC=1 SCAR=0.4
22 0 my $self = &myself;
23 0 good_args(@_ == 0);
24 0 $self->group($DIR)->export_to_env;
25 4 };
26 # BUILD: bindirs libdirs mandirs rootdirs
27 function "${DIR}dirs" => sub {
28 21 ▶ my $self = &myself;
Subroutine bindirs: called CC=2 SCAR=6.9
Subroutine __ANON__: called CC=2 SCAR=6.9
Subroutine mandirs: called CC=2 SCAR=6.9
29 21 good_args(@_ == 0);
30 21 my $group = $self->group($DIR);
31 21 ▶ return wantarray ? $group->found : $group;
Branch: 4 branches
BranchTrueFalseTotal
wantarray ? : 4 17 21
wantarray ? : 8 16 24
wantarray ? : 15 5 20
wantarray ? : 40 20 60
32 4 };
33 4 *rootdir = *rootdir = \&rootdirs;
34  
35 4 my $is_pl = $DIR ne "root";
36 4 ▶ my $NAMEDIR = $DIR . "dir" . ($is_pl && "s");
Condition66%2/3
$is_pl && 's'
!ll
130
MC/DC100%1/1
$is_pl && 's'
$is_pl
Truth table100%2/2
A
A= $is_pl
Aresult
00
11
37 4 ▶ my $has_have = $is_pl ? "have" : "has";
Branch: 1 branch
BranchTrueFalseTotal
$is_pl ? : 3 1 4
38 4 ▶ my $is_are = $is_pl ? "are" : "is";
Branch: 1 branch
BranchTrueFalseTotal
$is_pl ? : 3 1 4
39  
40 4 my %access_verb = (
41 wanted => $has_have,
42 allowed => $is_are,
43 );
44  
45 4 ▶ while (my($ACCESSOR, $VERB) = each %access_verb) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %access_verb) 8 4 12
46 function $NAMEDIR . "_" . $VERB => sub {
47 0 ▶ my $self = &myself;
Subroutine bindirs_have: not called CC=2 SCAR=9.9
Subroutine mandirs_have: not called CC=2 SCAR=9.9
48 0 ▶ my $action = join("_" => (@_ ? "set" : "get"), $NAMEDIR, $ACCESSOR);
Branch: 3 branches
BranchTrueFalseTotal
@_ ? : 0 0 0
@_ ? : 0 0 0
@_ ? : 4 7 11
49 0 $self->$action(@_);
50 8 };
51 }
52  
53 } ## for my @DIR (@_ALLDIRS)
54  
55 1 my @ACCESSORS = qw(allowed found wanted);
56  
57 1 for my $TYPE (@ACCESSORS) {
58 # BUILD: allowed found wanted
59 function $TYPE => sub {
60 0 ▶ my $self = &myself;
Subroutine found: not called CC=1 SCAR=3.3
Subroutine allowed: not called CC=1 SCAR=3.3
61 0 good_args(@_ == 1);
62 0 my $dir = shift;
63 0 return $self->group($dir)->$TYPE;
64 3 };
65  
66 3 for my $DIR (@_ALLDIRS) {
67 12 my $is_pl = $DIR ne "root";
68 12 ▶ my $NAMEDIR = $DIR . "dir" . ($is_pl && "s");
Condition66%2/3
$is_pl && 's'
!ll
390
MC/DC100%1/1
$is_pl && 's'
$is_pl
Truth table100%2/2
A
A= $is_pl
Aresult
00
11
69  
70 12 my $ACTION = $NAMEDIR . "_" . $TYPE;
71  
72 # BUILD: <{rootdir,{bin,lib,man}dirs}_{allowed,found,wanted}>
73 # BUILD: rootdir_allowed rootdir_found rootdir_wanted
74 # BUILD: bindirs_allowed bindirs_found bindirs_wanted
75 # BUILD: libdirs_allowed libdirs_found libdirs_wanted
76 # BUILD: mandirs_allowed mandirs_found mandirs_wanted
77 function $ACTION => sub {
78 0 ▶ my $self = &myself;
Subroutine bindirs_wanted: not called CC=1 SCAR=1.2
Subroutine mandirs_allowed: not called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=1.2
79 0 good_args(@_ == 0);
80 0 return $self->group($DIR)->$TYPE;
81 12 };
82  
83 12 for my $OP (qw(add get set)) {
84 36 my $FUNC_NAME = "${OP}_${ACTION}";
85 # BUILD: <{add,get,set}_{rootdir,{bin,lib,man}dirs}_{allowed,found,wanted}>
86 # BUILD: add_rootdir_allowed add_rootdir_found add_rootdir_wanted
87 # BUILD: add_bindirs_allowed add_bindirs_found add_bindirs_wanted
88 # BUILD: add_libdirs_allowed add_libdirs_found add_libdirs_wanted
89 # BUILD: add_mandirs_allowed add_mandirs_found add_mandirs_wanted
90 # BUILD: get_rootdir_allowed get_rootdir_found get_rootdir_wanted
91 # BUILD: get_bindirs_allowed get_bindirs_found get_bindirs_wanted
92 # BUILD: get_libdirs_allowed get_libdirs_found get_libdirs_wanted
93 # BUILD: get_mandirs_allowed get_mandirs_found get_mandirs_wanted
94 # BUILD: set_rootdir_allowed set_rootdir_found set_rootdir_wanted
95 # BUILD: set_bindirs_allowed set_bindirs_found set_bindirs_wanted
96 # BUILD: set_libdirs_allowed set_libdirs_found set_libdirs_wanted
97 # BUILD: set_mandirs_allowed set_mandirs_found set_mandirs_wanted
98 function $FUNC_NAME => sub {
99 2 ▶ my $self = &myself;
Subroutine set_libdirs_found: called CC=3 SCAR=11.9
Subroutine get_rootdir_wanted: called CC=3 SCAR=11.9
100 2 ▶ croak("$FUNC_NAME: no args allowed") if @_ && $OP eq "get";
Branch: 4 branches
BranchTrueFalseTotal
if @_ and $OP eq "get" 0 2 2
if @_ and $OP eq "get" 0 6 6
if @_ and $OP eq "get" 15 5 20
if @_ and $OP eq "get" 0 0 0
Condition50%6/12
@_ and $OP eq "get"
!ll&&!rl&&r
020
@_ and $OP eq "get"
!ll&&!rl&&r
060
@_ and $OP eq "get"
!ll&&!rl&&r
5150
@_ and $OP eq "get"
!ll&&!rl&&r
15450
MC/DC0%0/2
@_ and $OP eq "get"
@_ $OP eq "get"
MC/DC0%0/2
@_ and $OP eq "get"
@_ $OP eq "get"
MC/DC0%0/2
@_ and $OP eq "get"
@_ $OP eq "get"
MC/DC0%0/2
@_ and $OP eq "get"
@_ $OP eq "get"
Truth table33%1/3
A and B
A= @_B= $OP eq "get"
ABresult
0X0
100
111
Truth table33%1/3
A and B
A= @_B= $OP eq "get"
ABresult
0X0
100
111
Truth table66%2/3
A and B
A= @_B= $OP eq "get"
ABresult
0X0
100
111
Truth table66%2/3
A and B
A= @_B= $OP eq "get"
ABresult
0X0
100
111
101 2 return $self->group($DIR)->$TYPE->$OP(@_);
102 36 };
103 } ## for my $OP (qw(add get set))
104  
105 } ## for my @DIR (@_ALLDIRS)
106 } ## for my $TYPE (@ACCESSORS)
107  
108 1 1;
109  
110 __END__
« blib/lib/FindApp/Utils/Package.pm ↑ Summary lib/FindApp/Utils/Paths.pm »