blib/lib/Rex/Helper/Array.pm

filter: Statementstmt 60.0% 15 / 25 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 45.2% 19 / 42 CC 4 SCAR 22.6
CC
4
Cov
47%
in_array
20.0
array_uniq
2.0
BEGIN
1.0
CRAP 9.6
« lib/Rex/Pkg/SuSE.pm ↑ Summary lib/Rex/Virtualization/LibVirt/iflist.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Helper::Array;
6  
7 105 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 105 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 105 our $VERSION = '1.16.1'; # VERSION
11  
12 105 require Exporter;
13 105 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 105 ▶use vars qw(@EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 105 @EXPORT = qw(array_uniq in_array);
17  
18 0 ▶sub array_uniq {
Subroutine array_uniq: not called CC=1 SCAR=6.9
Pod undocumented
19 0 my (@array) = @_;
20  
21 0 my %all = ();
22 0 @all{@array} = 1;
23 0 return keys %all;
24 }
25  
26 0 ▶sub in_array {
Subroutine in_array: not called CC=4 SCAR=30.0
Pod undocumented
27 0 my ( $needle, @haystack ) = @_;
28  
29 my ($ret) = grep {
30 0 ▶ if ( ref $needle eq "RegExp" && $_ =~ $needle ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $needle eq 'RegExp' and $_ =~ /$needle/u) { } 0 0 0
elsif ($_ eq $needle) { } 0 0 0
Condition0%0/3
ref $needle eq "RegExp" and $_ =~ /$needle/u
!ll&&!rl&&r
000
MC/DC0%0/2
ref $needle eq "RegExp" and $_ =~ /$needle/u
ref $needle eq "RegExp" $_ =~ /$needle/u
Truth table0%0/3
A and B
A= ref $needle eq "RegExp"B= $_ =~ /$needle/u
ABresult
0X0
100
111
31 0 return $_;
32 }
33 elsif ( $_ eq $needle ) {
34 0 return $_;
35 }
36 } @haystack;
37  
38 0 return $ret;
39 }
40  
41 105 1;
« lib/Rex/Pkg/SuSE.pm ↑ Summary lib/Rex/Virtualization/LibVirt/iflist.pm »