Method/Regexp.pm

filter: Statementstmt 45.6% 26 / 57 Branchbran 6.6% 2 / 30 Conditioncond 6.2% 2 / 32 MC/DCmcdc 0.0% 0 / 19 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 2 totaltotal 25.0% 37 / 148 CC 30 SCAR 60.9
CC
30
Cov
25%
ANY
650.0
AUTOLOAD
6.3
new
4.6
CRAP 440.3
↑ Summary Method/Pool.pm »
1 package Net::DNS::Method::Regexp;
2  
3 2 require 5.005_62;
4  
5 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Net::DNS::Method;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use vars qw($VERSION @ISA $AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 $VERSION = '2.00';
12 2 our $DEBUG = 0;
13  
14 2 our @ISA = qw(Net::DNS::Method);
15  
16 1 ▶sub new {
Subroutine new: called CC=4 SCAR=15.2
Pod undocumented
17 1 my $type = shift;
18 1 ▶ my $class = ref($type) || $type || "Net::DNS::Method::Regexp";
Condition40%2/5
ref $type || $type || 'Net::DNS::Method::Regexp'
l!l
10
ref $type or $type
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $type || $type || 'Net::DNS::Method::Regexp'
ref $type $type
Truth table33%1/3
A or B
A= ref $typeB= $type
ABresult
1X1
011
000
19  
20 1 my $ref = shift;
21  
22 1 ▶ croak "Missing initialization parameters\n" unless ref($ref) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ref eq "HASH" 0 1 1
23  
24 1 return bless { ref => $ref }, $class;
25 }
26  
27 0 ▶sub ANY {
Subroutine ANY: not called CC=25 SCAR=64.8
Pod undocumented
28 0 my $self = shift;
29 0 my $q = shift;
30 0 my $ans = shift;
31  
32 0 ▶ warn "inside ANY" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $Net::DNS::Method::Regexp::DEBUG 0 0 0
33  
34 0 ▶ return NS_FAIL unless $self and $q and $ans;
Branch: 1 branch
BranchTrueFalseTotal
unless $self and $q and $ans 0 0 0
Condition0%0/6
$self and $q and $ans
!ll&&!rl&&r
000
$self and $q
!ll&&!rl&&r
000
MC/DC0%0/3
$self and $q and $ans
$self $q $ans
Truth table0%0/4
A and B and C
A= $selfB= $qC= $ans
ABCresult
0XX0
10X0
1100
1111
35  
36 0 my $qs = $q->qname . ' ' . $q->qclass . ' ' . $q->qtype;
37  
38 0 for my $re (sort { length $b <=> length $a } keys %{$self->{ref}}) {
39 0 ▶ if ($qs =~ /$re/ix)
Branch: 1 branch
BranchTrueFalseTotal
if ($qs =~ /$re/xi) 0 0 0
40 {
41  
42 0 ▶ warn "match on $re for question $qs" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $Net::DNS::Method::Regexp::DEBUG 0 0 0
43  
44 0 my $s = $self->{ref}->{$re};
45  
46 # First, push RRs in the corresponding zones
47  
48 0 for my $z (qw(answer authority additional question)) {
49 0 ▶ next unless exists $s->{$z} and defined $s->{$z};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $s->{$z} and defined $s->{$z} 0 0 0
Condition0%0/3
exists $s->{$z} and defined $s->{$z}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $s->{$z} and defined $s->{$z}
exists $s->{$z} defined $s->{$z}
Truth table0%0/3
A and B
A= exists $s->{$z}B= defined $s->{$z}
ABresult
0X0
100
111
50 croak "$re->$z must be undef or an array reference"
51 0 ▶ unless ref($s->{$z}) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $s->{$z} eq "ARRAY" 0 0 0
52 0 for my $rr (@{$s->{$z}}) {
53 0 $ans->safe_push($z, $rr);
54 }
55 }
56  
57 # Next, set the answer bits to the requested
58 # values
59  
60 $ans->header->ra($s->{ra})
61 0 ▶ if exists $s->{ra} and defined $s->{ra};
Branch: 1 branch
BranchTrueFalseTotal
if exists $s->{"ra"} and defined $s->{"ra"} 0 0 0
Condition0%0/3
exists $s->{"ra"} and defined $s->{"ra"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $s->{"ra"} and defined $s->{"ra"}
exists $s->{"ra"} defined $s->{"ra"}
Truth table0%0/3
A and B
A= exists $s->{"ra"}B= defined $s->{"ra"}
ABresult
0X0
100
111
62  
63 $ans->header->rd($s->{rd})
64 0 ▶ if exists $s->{rd} and defined $s->{rd};
Branch: 1 branch
BranchTrueFalseTotal
if exists $s->{"rd"} and defined $s->{"rd"} 0 0 0
Condition0%0/3
exists $s->{"rd"} and defined $s->{"rd"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $s->{"rd"} and defined $s->{"rd"}
exists $s->{"rd"} defined $s->{"rd"}
Truth table0%0/3
A and B
A= exists $s->{"rd"}B= defined $s->{"rd"}
ABresult
0X0
100
111
65  
66 $ans->header->aa($s->{aa})
67 0 ▶ if exists $s->{aa} and defined $s->{aa};
Branch: 1 branch
BranchTrueFalseTotal
if exists $s->{"aa"} and defined $s->{"aa"} 0 0 0
Condition0%0/3
exists $s->{"aa"} and defined $s->{"aa"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $s->{"aa"} and defined $s->{"aa"}
exists $s->{"aa"} defined $s->{"aa"}
Truth table0%0/3
A and B
A= exists $s->{"aa"}B= defined $s->{"aa"}
ABresult
0X0
100
111
68  
69 $ans->header->tc($s->{tc})
70 0 ▶ if exists $s->{tc} and defined $s->{tc};
Branch: 1 branch
BranchTrueFalseTotal
if exists $s->{"tc"} and defined $s->{"tc"} 0 0 0
Condition0%0/3
exists $s->{"tc"} and defined $s->{"tc"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $s->{"tc"} and defined $s->{"tc"}
exists $s->{"tc"} defined $s->{"tc"}
Truth table0%0/3
A and B
A= exists $s->{"tc"}B= defined $s->{"tc"}
ABresult
0X0
100
111
71  
72 # Next, set the answer's result code
73  
74 0 ▶ if (exists $s->{code} and defined $s->{code}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $s->{'code'} and defined $s->{'code'}) { } 0 0 0
Condition0%0/3
exists $s->{"code"} and defined $s->{"code"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $s->{"code"} and defined $s->{"code"}
exists $s->{"code"} defined $s->{"code"}
Truth table0%0/3
A and B
A= exists $s->{"code"}B= defined $s->{"code"}
ABresult
0X0
100
111
75 0 $ans->header->rcode($s->{code});
76 }
77 else {
78 0 $ans->header->rcode('NOERROR');
79 }
80  
81 # Finally, return the requested value or our
82 # default
83  
84 0 ▶ if (exists $s->{return} and defined $s->{return}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $s->{'return'} and defined $s->{'return'}) { } 0 0 0
Condition0%0/3
exists $s->{"return"} and defined $s->{"return"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $s->{"return"} and defined $s->{"return"}
exists $s->{"return"} defined $s->{"return"}
Truth table0%0/3
A and B
A= exists $s->{"return"}B= defined $s->{"return"}
ABresult
0X0
100
111
85 0 return $s->{return};
86 }
87 else {
88 0 return NS_OK | NS_STOP;
89 }
90 }
91 }
92 0 return NS_FAIL;
93 }
94  
95 1 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=3 SCAR=18.4
96 1 ▶ return undef if $AUTOLOAD eq 'Net::DNS::Method::Regexp::DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $Net::DNS::Method::Regexp::AUTOLOAD eq "Net::DNS::Method::Regexp::DESTROY" 1 0 1
97  
98 0 ▶ warn "call to $AUTOLOAD" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $Net::DNS::Method::Regexp::DEBUG 0 0 0
99  
100 0 goto &ANY;
101 }
102  
103 2 1;
104 __END__
↑ Summary Method/Pool.pm »