Any/Util.pm

filter: Statementstmt 34.0% 31 / 91 Branchbran 4.7% 2 / 42 Conditioncond 9.0% 1 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 37.5% 9 / 24 Podpod n/a totaltotal 24.5% 43 / 175 CC 28 SCAR 28.6
CC
28
Cov
24%
_gen_wanted
56.0
_debug_hexdump
32.2
_croak_bad_options
20.0
CRAP 17.5
« Any/SCP/Getter/Standard.pm ↑ Summary Any/Test.pm »
1 package Net::SSH::Any::Util;
2  
3 4 ▶BEGIN { *debug = \$Net::SSH::Any::debug }
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Time::HiRes ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 require Exporter;
12 4 our @ISA = qw(Exporter);
13 4 our @EXPORT = qw($debug _debug _debugf _debug_dump _debug_hexdump
14 _sub_options _croak_bad_options
15 _first_defined _array_or_scalar_to_list
16 _inc_numbered _gen_wanted
17 _scp_escape_name _scp_unescape_name
18 _warn);
19  
20 4 ▶our $debug ||= 0;
Condition50%1/2
our $debug ||= 0
l!l
04
MC/DC0%0/1
our $debug ||= 0
our $debug
Truth table50%1/2
A
A= our $debug
Aresult
11
00
21  
22 0 ▶sub _warn { warnings::warnif('Net::SSH::Any', join(': ', @_)) }
Subroutine _warn: not called CC=1 SCAR=6.9
23  
24 0 ▶sub _debug {
Subroutine _debug: not called CC=2 SCAR=17.9
25 0 local ($@, $!, $_);
26 0 ▶ print STDERR '#', (Time::HiRes::time() - $^T), ': ', (map { defined($_) ? $_ : '<undef>' } @_), "\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
27 }
28  
29 0 ▶sub _debugf {
Subroutine _debugf: not called CC=2 SCAR=17.9
30 0 my $t = shift;
31 0 ▶ _debug sprintf($t, map { defined($_) ? $_ : '<undef>' } @_);
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
32 }
33  
34 0 ▶sub _debug_dump {
Subroutine _debug_dump: not called CC=1 SCAR=6.9
35 0 require Data::Dumper;
36 0 local $Data::Dumper::Terse = 1;
37 0 local $Data::Dumper::Indent = 0;
38 0 my $head = shift;
39 0 _debug("$head: ", Data::Dumper::Dumper(@_));
40 }
41  
42 0 ▶sub _debug_hexdump {
Subroutine _debug_hexdump: not called CC=6 SCAR=34.7
43 4 ▶ no warnings qw(uninitialized);
Subroutine BEGIN: called CC=1 SCAR=0.0
44 0 my $head = shift;
45 0 local ($@, $!, $_);
46 0 _debugf("%s (%d bytes):", $head, length($_[0]));
47 0 ▶ if ($debug & 16384) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Net::SSH::Any::Util::debug & 16384) 0 0 0
48 0 my $data = shift;
49 0 ▶ while ($data =~ /(.{1,32})/smg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ /(.{1,32})/gms) 0 0 0
50 0 my $line = $1;
51 0 my @c= (( map { sprintf "%02x",$_ } unpack('C*', $line)),
52 ((" ") x 32))[0..31];
53 0 ▶ $line=~s/(.)/ my $c=$1; unpack("c",$c)>=32 ? $c : '.' /egms;
Branch: 1 branch
BranchTrueFalseTotal
unpack('c', $c) >= 32 ? : 0 0 0
54 0 print STDERR "#> ", join(" ", @c, '|', $line), "\n";
55 0 ▶ if (!($debug & 32768) and $data =~ /(=?.)/csmg) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $Net::SSH::Any::Util::debug & 32768 and $data =~ /(=?.)/cgms) 0 0 0
Condition0%0/3
not $Net::SSH::Any::Util::debug & 32768 and $data =~ /(=?.)/cgms
!ll&&!rl&&r
000
MC/DC0%0/2
not $Net::SSH::Any::Util::debug & 32768 and $data =~ /(=?.)/cgms
not $Net::SSH::Any::Util::debug & 32768 $data =~ /(=?.)/cgms
Truth table0%0/3
not(A) and B
A= not $Net::SSH::Any::Util::debug & 32768B= $data =~ /(=?.)/cgms
ABresult
0X0
100
111
56 0 print STDERR "#> ...\n";
57 0 last;
58 }
59 }
60 }
61 }
62  
63 0 ▶sub _first_defined { defined && return $_ for @_; return }
Subroutine _first_defined: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and return $_ 0 0 0
64  
65 4 my %good;
66  
67 20 ▶sub _sub_options {
Subroutine _sub_options: called CC=1 SCAR=0.0
68 20 my $sub = shift;
69 20 my $pkg = caller;
70 20 $good{"${pkg}::$sub"} = { map { $_ => 1 } @_ };
71 }
72  
73 0 ▶sub _croak_bad_options (\%) {
Subroutine _croak_bad_options: not called CC=4 SCAR=30.0
74 0 my $opts = shift;
75 0 ▶ if (%$opts) {
Branch: 1 branch
BranchTrueFalseTotal
if (%$opts) 0 0 0
76 0 my $sub = (caller 1)[3];
77 0 my $good = $good{$sub};
78 0 ▶ my @keys = ( $good ? grep !$good->{$_}, keys %$opts : keys %$opts);
Branch: 1 branch
BranchTrueFalseTotal
$good ? : 0 0 0
79 0 ▶ if (@keys) {
Branch: 1 branch
BranchTrueFalseTotal
if (@keys) 0 0 0
80 0 croak "Invalid or bad combination of options ('" . join("', '", @keys) . "')";
81 }
82 }
83 }
84  
85 3 ▶sub _array_or_scalar_to_list { map { defined($_) ? (ref $_ eq 'ARRAY' ? @$_ : $_ ) : () } @_ }
Subroutine _array_or_scalar_to_list: called CC=3 SCAR=12.0
Branch: 2 branches
BranchTrueFalseTotal
defined $_ ? : 3 0 3
ref $_ eq 'ARRAY' ? : 0 3 3
86  
87 0 ▶sub _inc_numbered {
Subroutine _inc_numbered: not called CC=4 SCAR=30.0
88 0 ▶ $_[0] =~ s{^(.*)\((\d+)\)((?:\.[^\.]*)?)$}{"$1(" . ($2+1) . ")$3"}e or
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ s/^(.*)\((\d+)\)((?:\.[^\.]*)?)$/"$1(" . ($2 + 1) . ")$3";/e or $_[0] =~ s/((?:\.[^\.]*)?)$/(1)$1/ 0 0 0
89 $_[0] =~ s{((?:\.[^\.]*)?)$}{(1)$1};
90 0 ▶ $debug and $debug & 128 and _debug("numbering to: $_[0]");
Branch: 1 branch
BranchTrueFalseTotal
$Net::SSH::Any::Util::debug and $Net::SSH::Any::Util::debug & 128 and _debug("numbering to: $_[0]") 0 0 0
Condition0%0/3
$Net::SSH::Any::Util::debug and $Net::SSH::Any::Util::debug & 128
!ll&&!rl&&r
000
MC/DC0%0/2
$Net::SSH::Any::Util::debug and $Net::SSH::Any::Util::debug & 128
$Net::SSH::Any::Util::debug $Net::SSH::Any::Util::debug & 128
Truth table0%0/3
A and B
A= $Net::SSH::Any::Util::debugB= $Net::SSH::Any::Util::debug & 128
ABresult
0X0
100
111
91 }
92  
93 0 ▶sub _gen_wanted {
Subroutine _gen_wanted: not called CC=7 SCAR=40.3
94 0 my ($ow, $onw) = my ($w, $nw) = @_;
95 0 ▶ if (ref $w eq 'Regexp') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $w eq "Regexp") 0 0 0
96 0 ▶ $w = sub { $_[0]{remote} =~ $ow }
Subroutine __ANON__: not called CC=1 SCAR=6.9
97 0 }
98  
99 0 ▶ if (ref $nw eq 'Regexp') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $nw eq "Regexp") 0 0 0
100 0 ▶ $nw = sub { $_[0]{remote} =~ $onw }
Subroutine __ANON__: not called CC=1 SCAR=6.9
101 0 }
102  
103 0 ▶ if (defined $w and defined $nw) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $w and defined $nw) 0 0 0
Condition0%0/3
defined $w and defined $nw
!ll&&!rl&&r
000
MC/DC0%0/2
defined $w and defined $nw
defined $w defined $nw
Truth table0%0/3
A and B
A= defined $wB= defined $nw
ABresult
0X0
100
111
104 0 ▶ return sub { &$nw and not &$w }
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
&$nw and not &$w 0 0 0
105 0 }
106  
107 0 ▶ return $w if defined $w;
Branch: 1 branch
BranchTrueFalseTotal
if defined $w 0 0 0
108 0 ▶ return sub { not &$nw } if defined $nw;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if defined $nw 0 0 0
109 0 undef;
110 }
111  
112 0 ▶sub _scp_unescape_name {
Subroutine _scp_unescape_name: not called CC=3 SCAR=24.8
113 0 ▶ s/\\\\|\\\^([@-Z])/$1 ? chr(ord($1) - 64) : '\\'/ge for @_;
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 0 0 0
114 }
115  
116 0 ▶sub _scp_escape_name {
Subroutine _scp_escape_name: not called CC=2 SCAR=17.9
117 0 for (@_) {
118 0 s/\\/\\\\/;
119 0 s/([\x00-\x1f])/'\\^' . chr(64 + ord($1))/ge;
120 }
121 }
122  
123 # sub _mkpath {
124 # my $path = shift;
125 # my @start = File::Spec->splitdir(File::Spec->rel2abs($path));
126 # my @end;
127 # while (@start) {
128 # my $start = File::Spec->join(@start);
129 # last if -d $start;
130 # push @end, pop @start;
131 # }
132 # while (@end) {
133 # push @start, pop @end;
134 # my $start = File::Spec->join(@start);
135 # return unless -d $start or mkdir $start;
136 # }
137 # 1;
138 # }
139  
140 4 1;
« Any/SCP/Getter/Standard.pm ↑ Summary Any/Test.pm »