lib/Rex/Helper/IP.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 10 / 10 Conditioncond 77.7% 7 / 9 MC/DCmcdc 66.6% 4 / 6 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 89.8% 53 / 59 CC 9 SCAR 15.5
CC
9
Cov
96%
get_server_and_port
7.0
is_ip
3.0
BEGIN
1.0
CRAP 4.7
« lib/Rex/Interface/Fs/Local.pm ↑ Summary lib/Rex/Virtualization/LibVirt/clone.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Helper::IP;
6  
7 3 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 our $VERSION = '1.16.1'; # VERSION
11  
12 3 ▶use Data::Validate::IP 'is_ipv4', 'is_ipv6';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 3 ▶sub is_ip {
Subroutine is_ip: called CC=3 SCAR=11.0
Pod undocumented
15 3 my ($ip) = @_;
16  
17 3 ▶ if ( is_ipv4($ip) || is_ipv6($ip) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_ipv4($ip) or is_ipv6($ip)) 2 1 3
Condition100%3/3
is_ipv4($ip) or is_ipv6($ip)
l!l&&r!l&&!r
111
MC/DC100%2/2
is_ipv4($ip) or is_ipv6($ip)
is_ipv4($ip) is_ipv6($ip)
Truth table100%3/3
A or B
A= is_ipv4($ip)B= is_ipv6($ip)
ABresult
1X1
011
000
18 2 return 1;
19 }
20 1 return 0;
21 }
22  
23 8 ▶sub get_server_and_port {
Subroutine get_server_and_port: called CC=7 SCAR=19.5
Pod undocumented
24 8 my ( $server, $default_port ) = @_;
25  
26 8 my ( $rs, $rp );
27  
28 8 ▶ if ( $server =~ m/:(\d+)$/ && !is_ipv6($server) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($server =~ /:(\d+)$/u and not is_ipv6($server)) 2 6 8
Condition100%3/3
$server =~ /:(\d+)$/u and not is_ipv6($server)
!ll&&!rl&&r
512
MC/DC100%2/2
$server =~ /:(\d+)$/u and not is_ipv6($server)
$server =~ /:(\d+)$/u not is_ipv6($server)
Truth table100%3/3
A and not(B)
A= $server =~ /:(\d+)$/uB= not is_ipv6($server)
ABresult
0X0
100
111
29 2 return split( /:/, $server );
30 }
31  
32 6 ▶ if ( $server =~ m/\/(\d+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($server =~ m[/(\d+)$]u) 3 3 6
33 3 return split( /\/(\d+)$/, $server );
34 }
35  
36 3 ▶ if ( is_ip($server) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_ip($server)) { } 2 1 3
37 2 ▶ if ( is_ipv6($server) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_ipv6($server)) { } 1 1 2
38 1 ( $rs, $rp ) = split( /\//, $server );
39 }
40 else {
41 1 ( $rs, $rp ) = split( /[:\/]/, $server );
42 }
43 }
44 else {
45 1 ( $rs, $rp ) = split( /[:\/]/, $server );
46 }
47  
48 3 ▶ $rp ||= $default_port;
Condition33%1/3
$rp ||= $default_port
l!l&&r!l&&!r
003
MC/DC0%0/2
$rp ||= $default_port
$rp $default_port
Truth table33%1/3
A ||= B
A= $rpB= $default_port
ABresult
1X1
011
000
49  
50 3 return ( $rs, $rp );
51 }
52  
53 3 1;
« lib/Rex/Interface/Fs/Local.pm ↑ Summary lib/Rex/Virtualization/LibVirt/clone.pm »