scripts/libdir.pl

filter: Statementstmt 82.3% 42 / 51 Branchbran 41.1% 14 / 34 Conditioncond 54.5% 6 / 11 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 65.1% 71 / 109 CC 7 SCAR 25.5
CC
7
Cov
65%
__ANON__
26.1
untaint_any
2.1
BEGIN
1.0
CRAP 12.8
« blib/lib/YATT/Lite/WebMVC0/DirApp.pm ↑ Summary blib/lib/YATT/Lite/Types.pm »
1 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 my @dir = do {
7 11 ▶ if ($ENV{DEBUG_INC}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"DEBUG_INC"}) 0 11 11
8 0 print STDERR "\$0=$0, rel2abs->", File::Spec->rel2abs($0), "\n";
9 }
10 11 ▶ my @d = (
Branch: 1 branch
BranchTrueFalseTotal
-r $0 && -l $0 ? : 0 11 11
Condition33%1/3
-r $0 and -l $0
!ll&&!rl&&r
0110
MC/DC0%0/2
-r $0 and -l $0
-r $0 -l $0
Truth table33%1/3
A and B
A= -r $0B= -l $0
ABresult
0X0
100
111
11 $_[0],
12 dirname(File::Spec->rel2abs($0)),
13 (-r $0 and -l $0) ? (
14 dirname(File::Spec->rel2abs(readlink($0), dirname($0))),
15 ) : (),
16 $FindBin::Bin,
17 $FindBin::Bin, # Just to avoid warning.
18 );
19 11 ▶ Carp::cluck("d=".join(", ", map {$_ // 'undef'} @d)) if $ENV{DEBUG_INC};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DEBUG_INC"} 0 11 11
Condition0%0/2
$_ // "undef"
l!l
00
MC/DC0%0/1
$_ // "undef"
$_
Truth table0%0/2
A
A= $_
Aresult
11
00
20 11 my %dup;
21 11 ▶ map {defined $_ && -d $_ && !$dup{$_}++ ? untaint_any($_) : ()} @d;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ && -d $_ && !$dup{$_}++ ? : 22 22 44
Condition83%5/6
defined $_ and -d $_ and not $dup{$_}++
!ll&&!rl&&r
111122
defined $_ and -d $_
!ll&&!rl&&r
11033
MC/DC66%2/3
defined $_ and -d $_ and not $dup{$_}++
defined $_ -d $_ not $dup{$_}++
Truth table75%3/4
A and B and not(C)
A= defined $_B= -d $_C= not $dup{$_}++
ABCresult
0XX0
10X0
1100
1111
22 };
23  
24 11 ▶unless (@dir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@dir) 0 11 11
25 0 Carp::croak("Can't find bindir!");
26 }
27  
28 11 ▶Carp::cluck("dir=@dir\n") if $ENV{DEBUG_INC};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DEBUG_INC"} 0 11 11
29  
30 28 ▶sub untaint_any {$_[0] =~ m{(.*)} and $1}
Subroutine untaint_any: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /(.*)/ and $1 28 0 28
31 11 ▶use base qw/File::Spec/;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 11 my (@libdir);
34  
35 11 foreach my $dir (@dir) {
36 22 ▶ if (grep {$_ eq 'YATT'} File::Spec->splitdir($dir)) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "YATT";} "File::Spec"->splitdir($dir)) 0 22 22
37 0 push @libdir, dirname(dirname($dir));
38 }
39  
40 22 ▶ if (-d (my $d = "$dir/../blib/lib")."/YATT") {
Branch: 1 branch
BranchTrueFalseTotal
if (-d (my $d = "$dir/../blib/lib") . '/YATT') 22 0 22
41 22 push @libdir, $d;
42 }
43 }
44  
45 810 ▶my $hook = sub {
Subroutine __ANON__: called CC=6 SCAR=32.6
46 810 my ($this, $orig_modfn) = @_;
47 810 ▶ return unless (my $modfn = $orig_modfn) =~ s!^YATT/!!;
Branch: 1 branch
BranchTrueFalseTotal
unless (my $modfn = $orig_modfn) =~ s[^YATT/][] 810 0 810
48 0 ▶ Carp::cluck("orig_modfn=$orig_modfn\n") if $ENV{DEBUG_INC};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DEBUG_INC"} 0 0 0
49 0 ▶ return unless -r (my $realfn = "$dir[0]/../$modfn");
Branch: 1 branch
BranchTrueFalseTotal
unless -r (my $realfn = "$dir[0]/../$modfn") 0 0 0
50 0 ▶ warn "=> found $realfn" if $ENV{DEBUG_INC};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DEBUG_INC"} 0 0 0
51 0 ▶ open my $fh, '<', $realfn or die "Can't open $realfn:$!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $realfn or die "Can't open ${realfn}:$!" 0 0 0
52 0 $fh;
53 11 };
54  
55 11 unshift @INC, $hook;
56  
57 11 ▶my $ins = $INC[$#INC] eq "." ? $#INC : @INC;
Branch: 1 branch
BranchTrueFalseTotal
$INC[$#INC] eq '.' ? : 11 0 11
58 11 splice @INC, $ins, 0, $hook, $hook;
59 # XXX: Why I need to put this into @INC-hook 3times?!
60  
61 11 require lib;
62  
63 11 ▶if (@libdir) {
Branch: 1 branch
BranchTrueFalseTotal
if (@libdir) 11 0 11
64 11 import lib @libdir;
65  
66 11 ▶ print STDERR join("\n", @libdir), "\n" if $ENV{DEBUG_INC};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DEBUG_INC"} 0 11 11
67 }
68  
69 # Should returns $dist_root
70  
71 11 return "$dir[0]/..";
« blib/lib/YATT/Lite/WebMVC0/DirApp.pm ↑ Summary blib/lib/YATT/Lite/Types.pm »