blib/lib/Net/DNS/Async/Simple.pm

filter: Statementstmt 89.1% 33 / 37 Branchbran 64.2% 9 / 14 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 79.3% 50 / 63 CC 10 SCAR 16.1
CC
10
Cov
80%
__ANON__
7.3
massDNSLookup
5.4
BEGIN
1.0
CRAP 5.0
↑ Summary
1 package Net::DNS::Async::Simple;
2 1 $Net::DNS::Async::Simple::VERSION = '1.161060';
3 1 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Net::DNS::Async;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 sub massDNSLookup {
8 1 ▶ my $list = shift
Subroutine massDNSLookup: called CC=5 SCAR=16.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
my $list = shift() or die "Net::DNS::Async::Simple: one argument required" 0 1 1
9 or die 'Net::DNS::Async::Simple: one argument required';
10 1 ▶ die 'Net::DNS::Async::Simple: first required argument must be an ARRAY reference'
Branch: 1 branch
BranchTrueFalseTotal
if not ref $list or ref $list ne "ARRAY" 0 1 1
Condition33%1/3
not ref $list or ref $list ne "ARRAY"
l!l&&r!l&&!r
001
MC/DC0%0/2
not ref $list or ref $list ne "ARRAY"
not ref $list ref $list ne "ARRAY"
Truth table33%1/3
not(A) or B
A= not ref $listB= ref $list ne "ARRAY"
ABresult
1X1
011
000
11 if not ref $list or ref $list ne 'ARRAY';
12 1 my $async = new Net::DNS::Async(QueueSize => 20, Retries => 3);
13  
14 my $callback = sub {
15 2 ▶ my ($index, $response) = @_;
Subroutine __ANON__: called CC=6 SCAR=19.9
16 2 ▶ if(not $response) { #timeout
Branch: 1 branch
BranchTrueFalseTotal
unless ($response) 0 2 2
17 0 $list->[$index]->{timeout} = 1;
18 0 return;
19 }
20 2 my @answers = $response->answer;
21 2 ▶ if(not scalar @answers) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @answers) 0 2 2
22 0 $list->[$index]->{error} = "returned no answers via";
23 0 return;
24 }
25 2 foreach my $answer (@answers) {
26 2 ▶ if(ref $answer eq 'Net::DNS::RR::A') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $answer eq 'Net::DNS::RR::A') { } 1 1 2
elsif (ref $answer eq 'Net::DNS::RR::PTR') { } 1 0 1
27 1 $list->[$index]->{name} = $answer->name;
28 1 $list->[$index]->{address} = $answer->address;
29 } elsif(ref $answer eq 'Net::DNS::RR::PTR') {
30 1 $list->[$index]->{ptrdname} = $answer->ptrdname;
31 }
32 }
33 1 };
34  
35 1 my $i = 0;
36 1 ▶ while($list->[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list->[$i]) 2 1 3
37 2 my $j = $i;
38 $async->add(
39 sub {
40 2 ▶ $callback->($j, @_)
Subroutine __ANON__: called CC=1 SCAR=0.0
41 2 }, @{$list->[$j]->{query}}
42 );
43 2 $i++;
44 }
45 1 $async->await;
46 1 return undef;
47 }
48  
49 1 1;
50  
51 __END__
↑ Summary