Sisimai/Reason.pm

filter: Statementstmt 97.0% 98 / 101 Branchbran 87.0% 47 / 54 Conditioncond 70.0% 49 / 70 MC/DCmcdc 41.4% 17 / 41 Subroutinesub 100% 11 / 11 Podpod 14.2% 1 / 7 totaltotal 78.5% 223 / 284 CC 60 SCAR 30.5
CC
60
Cov
86%
anotherone
31.5
find
23.4
match
8.1
CRAP 21.1
« Sisimai/Lhost/IMailServer.pm ↑ Summary Sisimai/Message.pm »
1 package Sisimai::Reason;
2 87 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 87 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 87 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 87 ▶use Sisimai::Eb;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 87 my $ModulePath = __PACKAGE__->path;
8 87 my $GetRetried = __PACKAGE__->retry;
9 87 my $ClassOrder = [
10 # 0. true() meethod in the following reasons are called from Reason->find()
11 [$Sisimai::Eb::ReFULL, $Sisimai::Eb::ReSIZE, $Sisimai::Eb::ReQUIT, $Sisimai::Eb::ReMOVE, $Sisimai::Eb::RePASS,
12 $Sisimai::Eb::ReAUTH, $Sisimai::Eb::ReUSER, $Sisimai::Eb::ReFILT, $Sisimai::Eb::ReQPTR, $Sisimai::Eb::ReNRFC,
13 $Sisimai::Eb::ReFAMA, $Sisimai::Eb::ReBODY, $Sisimai::Eb::ReFROM, $Sisimai::Eb::ReHOST, $Sisimai::Eb::ReSPAM,
14 $Sisimai::Eb::ReRATE, $Sisimai::Eb::ReBLOC, $Sisimai::Eb::ReTTLS, $Sisimai::Eb::Re00MX, $Sisimai::Eb::ReEXEC,
15 $Sisimai::Eb::ReWONT],
16  
17 # 1. match() method in the following reasons are called from Sisimai::Reason->find()
18 [$Sisimai::Eb::ReFULL, $Sisimai::Eb::ReSPAM, $Sisimai::Eb::ReEXEC, $Sisimai::Eb::RePASS, $Sisimai::Eb::RePROC,
19 $Sisimai::Eb::ReINET, $Sisimai::Eb::ReQUIT, $Sisimai::Eb::ReDISK, $Sisimai::Eb::ReSTOP, $Sisimai::Eb::ReUNIX,
20 $Sisimai::Eb::ReSAFE, $Sisimai::Eb::ReWONT, $Sisimai::Eb::ReCOMM, $Sisimai::Eb::ReTIME],
21  
22 [$Sisimai::Eb::ReFULL, $Sisimai::Eb::ReSIZE, $Sisimai::Eb::ReQUIT, $Sisimai::Eb::ReUSER, $Sisimai::Eb::ReFILT,
23 $Sisimai::Eb::ReFROM, $Sisimai::Eb::ReHOST, $Sisimai::Eb::ReSPAM, $Sisimai::Eb::ReRATE, $Sisimai::Eb::ReBLOC,
24 $Sisimai::Eb::ReAUTH, $Sisimai::Eb::ReTTLS, $Sisimai::Eb::ReSAFE, $Sisimai::Eb::RePROC, $Sisimai::Eb::ReINET,
25 $Sisimai::Eb::ReTIME, $Sisimai::Eb::ReBODY, $Sisimai::Eb::ReMOVE, $Sisimai::Eb::ReDISK, $Sisimai::Eb::Re00MX,
26 $Sisimai::Eb::ReUNIX, $Sisimai::Eb::RePASS, $Sisimai::Eb::ReSTOP, $Sisimai::Eb::ReCOMM, $Sisimai::Eb::Re___1],
27 ];
28  
29 173 ▶sub retry {
Subroutine retry: called CC=1 SCAR=0.0
Pod undocumented
30 # Reason list better to retry detecting an error reason
31 # @return [Hash] Reason list
32 return {
33 173 $Sisimai::Eb::Re___0 => 1, $Sisimai::Eb::Re___1 => 1, $Sisimai::Eb::RePROC => 1, $Sisimai::Eb::ReSAFE => 1,
34 $Sisimai::Eb::ReTIME => 1, $Sisimai::Eb::ReINET => 1, $Sisimai::Eb::ReHOST => 1, $Sisimai::Eb::ReUSER => 1,
35 };
36 }
37  
38 9580 ▶sub is_explicit {
Subroutine is_explicit: called CC=5 SCAR=16.1
Pod undocumented
39 # is_explicit() returns 0 when the argument is empty or is "Undefined" or is "OnHold"
40 # @param string argv1 Reason name
41 # @return bool false: The reaosn is not explicit
42 9580 my $class = shift;
43 9580 ▶ my $argv1 = shift || return 0;
Condition100%2/2
shift() || (return 0)
l!l
37445836
MC/DC100%1/1
shift() || (return 0)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
44  
45 3744 ▶ return 0 if $argv1 eq $Sisimai::Eb::Re___0 || $argv1 eq $Sisimai::Eb::Re___1 || $argv1 eq "";
Branch: 1 branch
BranchTrueFalseTotal
if $argv1 eq $Sisimai::Eb::Re___0 or $argv1 eq $Sisimai::Eb::Re___1 or $argv1 eq "" 63 3681 3744
Condition83%5/6
$argv1 eq $Sisimai::Eb::Re___0 or $argv1 eq $Sisimai::Eb::Re___1 or $argv1 eq ""
l!l&&r!l&&!r
6303681
$argv1 eq $Sisimai::Eb::Re___0 or $argv1 eq $Sisimai::Eb::Re___1
l!l&&r!l&&!r
10533681
MC/DC66%2/3
$argv1 eq $Sisimai::Eb::Re___0 or $argv1 eq $Sisimai::Eb::Re___1 or $argv1 eq ""
$argv1 eq $Sisimai::Eb::Re___0 $argv1 eq $Sisimai::Eb::Re___1 $argv1 eq ""
Truth table75%3/4
A or B or C
A= $argv1 eq $Sisimai::Eb::Re___0B= $argv1 eq $Sisimai::Eb::Re___1C= $argv1 eq ""
ABCresult
1XX1
01X1
0011
0000
46 3681 return 1;
47 }
48  
49 172 ▶sub index {
Subroutine index: called CC=1 SCAR=0.0
Pod undocumented
50 # All the error reason list Sisimai support
51 # @return [Array] Reason list
52 return [
53 172 $Sisimai::Eb::ReAUTH, $Sisimai::Eb::ReFAMA, $Sisimai::Eb::ReBLOC, $Sisimai::Eb::ReBODY, $Sisimai::Eb::ReSENT,
54 $Sisimai::Eb::ReSIZE, $Sisimai::Eb::ReTIME, $Sisimai::Eb::ReTTLS, $Sisimai::Eb::ReFEED, $Sisimai::Eb::ReFILT,
55 $Sisimai::Eb::ReMOVE, $Sisimai::Eb::ReHOST, $Sisimai::Eb::ReFULL, $Sisimai::Eb::ReUNIX, $Sisimai::Eb::ReINET,
56 $Sisimai::Eb::RePASS, $Sisimai::Eb::Re00MX, $Sisimai::Eb::ReNRFC, $Sisimai::Eb::Re___1, $Sisimai::Eb::ReWONT,
57 $Sisimai::Eb::ReFROM, $Sisimai::Eb::ReQPTR, $Sisimai::Eb::ReRATE, $Sisimai::Eb::ReSAFE, $Sisimai::Eb::ReSPAM,
58 $Sisimai::Eb::ReSTOP, $Sisimai::Eb::ReQUIT, $Sisimai::Eb::ReCOMM, $Sisimai::Eb::RePROC, $Sisimai::Eb::ReDISK,
59 $Sisimai::Eb::ReUSER, $Sisimai::Eb::ReAWAY, $Sisimai::Eb::ReEXEC,
60 ];
61 }
62  
63 89 ▶sub path {
Subroutine path: called CC=2 SCAR=6.9
Pod undocumented
64 # Returns Sisimai::Reason::* module path table
65 # @return [Hash] Module path table
66 # @since v4.25.6
67 89 my $class = shift;
68 89 my $index = __PACKAGE__->index;
69 89 my $table = {}; $table->{ __PACKAGE__.'::'.$_ } = 'Sisimai/Reason/'.$_.'.pm' for @$index;
70 89 return $table;
71 }
72  
73 2502 ▶sub find {
Subroutine find: called CC=21 SCAR=31.5
Pod undocumented
74 # Detect the bounce reason
75 # @param [Hash] argvs Decoded email object
76 # @return [String] Bounce reason or an empty string if the argument is missing or not HASH
77 # @see anotherone
78 2502 my $class = shift;
79 2502 ▶ my $argvs = shift // return "";
Condition100%2/2
shift() // (return "")
l!l
25011
MC/DC100%1/1
shift() // (return "")
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
80  
81 # Return a reason text already decided except a reason matched with the regular expression of
82 # Sisimai::Reason->retry() method.
83 2501 ▶ return $argvs->{'reason'} if( (not exists $GetRetried->{ $argvs->{'reason'} }) && $argvs->{'reason'} );
Branch: 1 branch
BranchTrueFalseTotal
if not exists $$GetRetried{$argvs->{"reason"}} and $argvs->{"reason"} 0 2501 2501
Condition66%2/3
not exists $$GetRetried{$argvs->{"reason"}} and $argvs->{"reason"}
!ll&&!rl&&r
23322680
MC/DC0%0/2
not exists $$GetRetried{$argvs->{"reason"}} and $argvs->{"reason"}
not exists $$GetRetried{$argvs->{"reason"}} $argvs->{"reason"}
Truth table66%2/3
not(A) and B
A= not exists $$GetRetried{$argvs->{"reason"}}B= $argvs->{"reason"}
ABresult
0X0
100
111
84 2501 ▶ return $Sisimai::Eb::ReSENT if substr($argvs->{'deliverystatus'}, 0, 2) eq '2.';
Branch: 1 branch
BranchTrueFalseTotal
if substr($argvs->{"deliverystatus"}, 0, 2) eq "2." 2 2499 2501
85  
86 2499 my $reasontext = '';
87 2499 ▶ my $issuedcode = $argvs->{'diagnosticcode'} || '';
Condition100%2/2
$argvs->{'diagnosticcode'} || ''
l!l
248910
MC/DC100%1/1
$argvs->{'diagnosticcode'} || ''
$argvs->{'diagnosticcode'}
Truth table100%2/2
A
A= $argvs->{'diagnosticcode'}
Aresult
11
00
88 2499 ▶ my $codeformat = $argvs->{'diagnostictype'} || '';
Condition50%1/2
$argvs->{'diagnostictype'} || ''
l!l
24990
MC/DC0%0/1
$argvs->{'diagnostictype'} || ''
$argvs->{'diagnostictype'}
Truth table50%1/2
A
A= $argvs->{'diagnostictype'}
Aresult
11
00
89 2499 ▶ if( $codeformat eq 'SMTP' || $codeformat eq '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($codeformat eq "SMTP" or $codeformat eq "") 2428 71 2499
Condition66%2/3
$codeformat eq "SMTP" or $codeformat eq ""
l!l&&r!l&&!r
2428071
MC/DC50%1/2
$codeformat eq "SMTP" or $codeformat eq ""
$codeformat eq "SMTP" $codeformat eq ""
Truth table66%2/3
A or B
A= $codeformat eq "SMTP"B= $codeformat eq ""
ABresult
1X1
011
000
90 # Diagnostic-Code: SMTP; ... or empty value
91 2428 for my $e ( $ClassOrder->[0]->@* ) {
92 # Check the values of Diagnostic-Code: and Status: fields using true() method of each
93 # child class in Sisimai::Reason
94 27423 my $p = 'Sisimai::Reason::'.$e;
95 27423 require $ModulePath->{ $p };
96  
97 27423 ▶ next unless $p->true($argvs);
Branch: 1 branch
BranchTrueFalseTotal
unless $p->true($argvs) 25587 1836 27423
98 1836 $reasontext = $p->text;
99 1836 last;
100 }
101 }
102  
103 2499 ▶ if( not $reasontext || $reasontext eq $Sisimai::Eb::Re___0 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reasontext or $reasontext eq $Sisimai::Eb::Re___0) 663 1836 2499
Condition66%2/3
$reasontext or $reasontext eq $Sisimai::Eb::Re___0
l!l&&r!l&&!r
18360663
MC/DC50%1/2
$reasontext or $reasontext eq $Sisimai::Eb::Re___0
$reasontext $reasontext eq $Sisimai::Eb::Re___0
Truth table66%2/3
A or B
A= $reasontextB= $reasontext eq $Sisimai::Eb::Re___0
ABresult
1X1
011
000
104 # Bounce reason is not detected yet.
105 663 $reasontext = __PACKAGE__->anotherone($argvs);
106 663 ▶ $reasontext = '' if $reasontext eq $Sisimai::Eb::Re___0;
Branch: 1 branch
BranchTrueFalseTotal
if $reasontext eq $Sisimai::Eb::Re___0 0 663 663
107 663 ▶ $reasontext ||= $Sisiimai::Eb::ReTIME if $argvs->{'action'} eq $Sisimai::Eb::AeSTAY;
Branch: 1 branch
BranchTrueFalseTotal
if $argvs->{"action"} eq $Sisimai::Eb::AeSTAY 52 611 663
Condition33%1/3
$reasontext ||= $Sisiimai::Eb::ReTIME
l!l&&r!l&&!r
5200
MC/DC0%0/2
$reasontext ||= $Sisiimai::Eb::ReTIME
$reasontext $Sisiimai::Eb::ReTIME
Truth table33%1/3
A ||= B
A= $reasontextB= $Sisiimai::Eb::ReTIME
ABresult
1X1
011
000
108 663 ▶ return $reasontext if $reasontext;
Branch: 1 branch
BranchTrueFalseTotal
if $reasontext 621 42 663
109  
110 # Try to match with message patterns in Sisimai::Reason::Vacation
111 42 require Sisimai::Reason::Vacation;
112 42 ▶ $reasontext = $Sisimai::Eb::ReAWAY if Sisimai::Reason::Vacation->match(lc $issuedcode);
Branch: 1 branch
BranchTrueFalseTotal
if "Sisimai::Reason::Vacation"->match(lc $issuedcode) 0 42 42
113 42 ▶ $reasontext ||= $Sisimai::Eb::Re___1 if $issuedcode;
Branch: 1 branch
BranchTrueFalseTotal
if $issuedcode 32 10 42
Condition33%1/3
$reasontext ||= $Sisimai::Eb::Re___1
l!l&&r!l&&!r
0320
MC/DC0%0/2
$reasontext ||= $Sisimai::Eb::Re___1
$reasontext $Sisimai::Eb::Re___1
Truth table33%1/3
A ||= B
A= $reasontextB= $Sisimai::Eb::Re___1
ABresult
1X1
011
000
114 42 ▶ $reasontext ||= $Sisimai::Eb::Re___0;
Condition66%2/3
$reasontext ||= $Sisimai::Eb::Re___0
l!l&&r!l&&!r
32100
MC/DC0%0/2
$reasontext ||= $Sisimai::Eb::Re___0
$reasontext $Sisimai::Eb::Re___0
Truth table66%2/3
A ||= B
A= $reasontextB= $Sisimai::Eb::Re___0
ABresult
1X1
011
000
115 }
116 1878 return $reasontext;
117 }
118  
119 664 ▶sub anotherone {
Subroutine anotherone: called CC=28 SCAR=34.5
Pod undocumented
120 # Detect the other bounce reason, fall back method for find()
121 # @param [Hash] argvs Decoded email structure
122 # @return [String] Bounce reason or an empty string if the argument is missing or not HASH
123 # @see find()
124 664 my $class = shift;
125 664 ▶ my $argvs = shift // return ""; return $argvs->{'reason'} if $argvs->{'reason'};
Branch: 1 branch
BranchTrueFalseTotal
if $argvs->{"reason"} 25 638 663
Condition100%2/2
shift() // (return "")
l!l
6631
MC/DC100%1/1
shift() // (return "")
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
126  
127 638 require Sisimai::SMTP::Status;
128 638 ▶ my $issuedcode = lc $argvs->{'diagnosticcode'} // '';
Condition50%1/2
lc $argvs->{"diagnosticcode"} // ""
l!l
6380
MC/DC0%0/1
lc $argvs->{"diagnosticcode"} // ""
lc $argvs->{"diagnosticcode"}
Truth table50%1/2
A
A= lc $argvs->{"diagnosticcode"}
Aresult
11
00
129 638 ▶ my $codeformat = $argvs->{'diagnostictype'} // '';
Condition50%1/2
$argvs->{"diagnostictype"} // ""
l!l
6380
MC/DC0%0/1
$argvs->{"diagnostictype"} // ""
$argvs->{"diagnostictype"}
Truth table50%1/2
A
A= $argvs->{"diagnostictype"}
Aresult
11
00
130 638 ▶ my $actiontext = $argvs->{'action'} // '';
Condition50%1/2
$argvs->{"action"} // ""
l!l
6380
MC/DC0%0/1
$argvs->{"action"} // ""
$argvs->{"action"}
Truth table50%1/2
A
A= $argvs->{"action"}
Aresult
11
00
131 638 ▶ my $statuscode = $argvs->{'deliverystatus'} // '';
Condition50%1/2
$argvs->{"deliverystatus"} // ""
l!l
6380
MC/DC0%0/1
$argvs->{"deliverystatus"} // ""
$argvs->{"deliverystatus"}
Truth table50%1/2
A
A= $argvs->{"deliverystatus"}
Aresult
11
00
132 638 ▶ my $reasontext = Sisimai::SMTP::Status->name($statuscode) || '';
Condition100%2/2
'Sisimai::SMTP::Status'->name($statuscode) || ''
l!l
245393
MC/DC100%1/1
'Sisimai::SMTP::Status'->name($statuscode) || ''
'Sisimai::SMTP::Status'->name($statuscode)
Truth table100%2/2
A
A= 'Sisimai::SMTP::Status'->name($statuscode)
Aresult
11
00
133 638 ▶ my $trytomatch = $reasontext eq '' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$reasontext eq '' ? : 393 245 638
134 638 ▶ $trytomatch = 1 if exists $GetRetried->{ $reasontext } || $codeformat ne 'SMTP';
Branch: 1 branch
BranchTrueFalseTotal
if exists $GetRetried->{$reasontext} or $codeformat ne "SMTP" 246 392 638
Condition100%3/3
exists $GetRetried->{$reasontext} or $codeformat ne "SMTP"
l!l&&r!l&&!r
21036392
MC/DC100%2/2
exists $GetRetried->{$reasontext} or $codeformat ne "SMTP"
exists $GetRetried->{$reasontext} $codeformat ne "SMTP"
Truth table100%3/3
A or B
A= exists $GetRetried->{$reasontext}B= $codeformat ne "SMTP"
ABresult
1X1
011
000
135  
136 638 ▶ while($trytomatch) {
Branch: 1 branch
BranchTrueFalseTotal
if ($trytomatch) 603 35 638
137 # Could not decide the reason by the value of Status:
138 603 for my $e ( $ClassOrder->[1]->@* ) {
139 # Trying to match with other patterns in Sisimai::Reason::* classes
140 6222 my $p = 'Sisimai::Reason::'.$e;
141 6222 require $ModulePath->{ $p };
142  
143 6222 ▶ next unless $p->match($issuedcode);
Branch: 1 branch
BranchTrueFalseTotal
unless $p->match($issuedcode) 5769 453 6222
144 453 $reasontext = $e;
145 453 last;
146 }
147 603 ▶ last if $reasontext;
Branch: 1 branch
BranchTrueFalseTotal
if $reasontext 520 83 603
148  
149 # Check the value of Status:
150 83 ▶ my $code2digit = substr($statuscode, 0, 3) || '';
Condition100%2/2
substr($statuscode, 0, 3) || ''
l!l
6716
MC/DC100%1/1
substr($statuscode, 0, 3) || ''
substr($statuscode, 0, 3)
Truth table100%2/2
A
A= substr($statuscode, 0, 3)
Aresult
11
00
151 83 ▶ if( $code2digit eq '5.6' || $code2digit eq '4.6' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($code2digit eq '5.6' or $code2digit eq '4.6') { } 0 83 83
elsif ($code2digit eq '5.7' or $code2digit eq '4.7') { } 0 83 83
elsif (CORE::index($codeformat, 'X-UNIX') == 0) { } 15 68 83
Condition33%1/3
$code2digit eq "5.6" or $code2digit eq "4.6"
l!l&&r!l&&!r
0083
MC/DC0%0/2
$code2digit eq "5.6" or $code2digit eq "4.6"
$code2digit eq "5.6" $code2digit eq "4.6"
Truth table33%1/3
A or B
A= $code2digit eq "5.6"B= $code2digit eq "4.6"
ABresult
1X1
011
000
152 # X.6.0 Other or undefined media error
153 0 $reasontext = $Sisimai::Eb::ReBODY;
154  
155 ▶ } elsif( $code2digit eq '5.7' || $code2digit eq '4.7' ) {
Condition33%1/3
$code2digit eq "5.7" or $code2digit eq "4.7"
l!l&&r!l&&!r
0083
MC/DC0%0/2
$code2digit eq "5.7" or $code2digit eq "4.7"
$code2digit eq "5.7" $code2digit eq "4.7"
Truth table33%1/3
A or B
A= $code2digit eq "5.7"B= $code2digit eq "4.7"
ABresult
1X1
011
000
156 # X.7.0 Other or undefined security status
157 0 $reasontext = $Sisimai::Eb::ReSAFE;
158  
159 } elsif( CORE::index($codeformat, 'X-UNIX') == 0 ) {
160 # Diagnostic-Code: X-UNIX; ..., X-Postfix, or other X-*
161 15 $reasontext = $Sisimai::Eb::ReUNIX;
162  
163 } else {
164 # 50X Syntax Error?
165 68 require Sisimai::Reason::SyntaxError;
166 68 ▶ $reasontext = $Sisimai::Eb::ReCOMM if Sisimai::Reason::SyntaxError->true($argvs);
Branch: 1 branch
BranchTrueFalseTotal
if "Sisimai::Reason::SyntaxError"->true($argvs) 0 68 68
167 }
168 83 ▶ last if $reasontext;
Branch: 1 branch
BranchTrueFalseTotal
if $reasontext 15 68 83
169  
170 # Check the value of Action: field, first
171 68 ▶ if( CORE::index($actiontext, $Sisimai::Eb::AeSTAY) == 0 || CORE::index($actiontext, 'expired') == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::index($actiontext, $Sisimai::Eb::AeSTAY) == 0 or CORE::index($actiontext, 'expired') == 0) { } 5 63 68
Condition66%2/3
CORE::index($actiontext, $Sisimai::Eb::AeSTAY) == 0 or CORE::index($actiontext, "expired") == 0
l!l&&r!l&&!r
5063
MC/DC50%1/2
CORE::index($actiontext, $Sisimai::Eb::AeSTAY) == 0 or CORE::index($actiontext, "expired") == 0
CORE::index($actiontext, $Sisimai::Eb::AeSTAY) == 0 CORE::index($actiontext, "expired") == 0
Truth table66%2/3
A or B
A= CORE::index($actiontext, $Sisimai::Eb::AeSTAY) == 0B= CORE::index($actiontext, "expired") == 0
ABresult
1X1
011
000
172 # Action: delayed, expired
173 5 $reasontext = $Sisimai::Eb::ReTIME;
174  
175 } else {
176 # Check the value of SMTP command
177 63 ▶ my $thecommand = $argvs->{'command'} // '';
Condition50%1/2
$argvs->{"command"} // ""
l!l
630
MC/DC0%0/1
$argvs->{"command"} // ""
$argvs->{"command"}
Truth table50%1/2
A
A= $argvs->{"command"}
Aresult
11
00
178 63 ▶ if( $thecommand eq $Sisimai::Eb::CeEHLO || $thecommand eq $Sisimai::Eb::CeHELO ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($thecommand eq $Sisimai::Eb::CeEHLO or $thecommand eq $Sisimai::Eb::CeHELO) 21 42 63
Condition100%3/3
$thecommand eq $Sisimai::Eb::CeEHLO or $thecommand eq $Sisimai::Eb::CeHELO
l!l&&r!l&&!r
51642
MC/DC100%2/2
$thecommand eq $Sisimai::Eb::CeEHLO or $thecommand eq $Sisimai::Eb::CeHELO
$thecommand eq $Sisimai::Eb::CeEHLO $thecommand eq $Sisimai::Eb::CeHELO
Truth table100%3/3
A or B
A= $thecommand eq $Sisimai::Eb::CeEHLOB= $thecommand eq $Sisimai::Eb::CeHELO
ABresult
1X1
011
000
179 # Rejected at connection or after EHLO|HELO
180 21 $reasontext = $Sisimai::Eb::ReBLOC;
181 }
182 }
183 68 last;
184 }
185 638 return $reasontext;
186 }
187  
188 189 ▶sub match {
Subroutine match: called CC=8 SCAR=20.9
Pod documented
189 # Detect the bounce reason from given text
190 # @param [String] argv1 Error message
191 # @return [String] Bounce reason
192 189 my $class = shift;
193 189 ▶ my $argv1 = shift // return "";
Condition100%2/2
shift() // (return "")
l!l
1881
MC/DC100%1/1
shift() // (return "")
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
194  
195 188 my $reasontext = '';
196 188 my $issuedcode = lc $argv1;
197  
198 # Diagnostic-Code: SMTP; ... or empty value
199 188 for my $e ( $ClassOrder->[2]->@* ) {
200 # Check the values of Diagnostic-Code: and Status: fields using true() method of each child
201 # class in Sisimai::Reason
202 2149 my $p = 'Sisimai::Reason::'.$e;
203 2149 require $ModulePath->{ $p };
204  
205 2149 ▶ next unless $p->match($issuedcode);
Branch: 1 branch
BranchTrueFalseTotal
unless $p->match($issuedcode) 2005 144 2149
206 144 $reasontext = $p->text;
207 144 last;
208 }
209 188 ▶ return $reasontext if $reasontext;
Branch: 1 branch
BranchTrueFalseTotal
if $reasontext 144 44 188
210  
211 44 ▶ if( CORE::index(uc $issuedcode, 'X-UNIX; ') > -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::index(uc $issuedcode, 'X-UNIX; ') != -1) { } 0 44 44
212 # X-Unix; ...
213 0 $reasontext = $Sisimai::Eb::ReUNIX;
214  
215 } else {
216 # Detect the bounce reason from "Status:" code
217 44 require Sisimai::SMTP::Status;
218 44 ▶ my $cv = Sisimai::SMTP::Status->find($argv1) || '';
Condition100%2/2
'Sisimai::SMTP::Status'->find($argv1) || ''
l!l
3014
MC/DC100%1/1
'Sisimai::SMTP::Status'->find($argv1) || ''
'Sisimai::SMTP::Status'->find($argv1)
Truth table100%2/2
A
A= 'Sisimai::SMTP::Status'->find($argv1)
Aresult
11
00
219 44 ▶ $reasontext = Sisimai::SMTP::Status->name($cv) || $Sisimai::Eb::Re___0;
Condition66%2/3
'Sisimai::SMTP::Status'->name($cv) || $Sisimai::Eb::Re___0
l!l&&r!l&&!r
28160
MC/DC0%0/2
'Sisimai::SMTP::Status'->name($cv) || $Sisimai::Eb::Re___0
'Sisimai::SMTP::Status'->name($cv) $Sisimai::Eb::Re___0
Truth table66%2/3
A || B
A= 'Sisimai::SMTP::Status'->name($cv)B= $Sisimai::Eb::Re___0
ABresult
1X1
011
000
220 }
221 44 return $reasontext;
222 }
223  
224 87 1;
225 __END__
« Sisimai/Lhost/IMailServer.pm ↑ Summary Sisimai/Message.pm »