Sisimai/Lhost/X2.pm

filter: Statementstmt 97.9% 48 / 49 Branchbran 93.3% 28 / 30 Conditioncond 72.4% 21 / 29 MC/DCmcdc 40.0% 6 / 15 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 84.7% 111 / 131 CC 29 SCAR 32.6
CC
29
Cov
90%
inquire
30.3
BEGIN
1.0
BEGIN
1.0
CRAP 26.0
« Sisimai/Lhost/Gmail.pm ↑ Summary Sisimai/Lhost/MailMarshal.pm »
1 package Sisimai::Lhost::X2;
2 37 ▶use parent 'Sisimai::Lhost';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 37 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub description { 'Unknown MTA #2' }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
8 913 ▶sub inquire {
Subroutine inquire: called CC=29 SCAR=34.1
Pod documented
9 # Detect an error from Unknown MTA #2
10 # @param [Hash] mhead Message headers of a bounce email
11 # @param [String] mbody Message body of a bounce email
12 # @return [Hash] Bounce data list and message/rfc822 part
13 # @return [undef] failed to decode or the arguments are missing
14 # @since v4.1.7
15 913 my $class = shift;
16 913 ▶ my $mhead = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
9121
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
17 912 ▶ my $mbody = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
9111
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
18 911 ▶ my $match = 0; $match ||= 1 if index($mhead->{'from'}, 'MAILER-DAEMON@') > -1;
Branch: 1 branch
BranchTrueFalseTotal
if index($mhead->{"from"}, "MAILER-DAEMON\@") != -1 315 596 911
Condition50%1/2
$match ||= 1
l!l
0315
MC/DC0%0/1
$match ||= 1
$match
Truth table50%1/2
A
A= $match
Aresult
11
00
19 911 ▶ $match ||= 1 if index($mhead->{'subject'}, 'Delivery failure') == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($mhead->{"subject"}, "Delivery failure") == 0 21 890 911
Condition100%2/2
$match ||= 1
l!l
165
MC/DC100%1/1
$match ||= 1
$match
Truth table100%2/2
A
A= $match
Aresult
11
00
20 911 ▶ $match ||= 1 if index($mhead->{'subject'}, 'failure delivery') == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($mhead->{"subject"}, "failure delivery") == 0 5 906 911
Condition50%1/2
$match ||= 1
l!l
50
MC/DC0%0/1
$match ||= 1
$match
Truth table50%1/2
A
A= $match
Aresult
11
00
21 911 ▶ $match ||= 1 if index($mhead->{'subject'}, 'failed delivery') == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($mhead->{"subject"}, "failed delivery") == 0 5 906 911
Condition50%1/2
$match ||= 1
l!l
50
MC/DC0%0/1
$match ||= 1
$match
Truth table50%1/2
A
A= $match
Aresult
11
00
22 911 ▶ return undef unless $match > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $match > 0 591 320 911
23  
24 320 state $indicators = __PACKAGE__->INDICATORS;
25 320 state $boundaries = ['--- Original message follows.'];
26 320 state $startingof = {
27 'message' => [
28 'Unable to deliver message to the following address',
29 'This Delivery Status Notification is sent from MTA',
30 ]
31 };
32  
33 320 ▶ my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $emailparts->[0] 0 320 320
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
l!l
3200
MC/DC0%0/1
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
"Sisimai::RFC5322"->part($mbody, $boundaries)
Truth table50%1/2
A
A= "Sisimai::RFC5322"->part($mbody, $boundaries)
Aresult
11
00
34 320 my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef;
35 320 my $readcursor = 0; # (Integer) Points the current cursor position
36 320 my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
37  
38 320 for my $e ( split("\n", $emailparts->[0]) ) {
39 # Read error messages and delivery status lines from the head of the email to the previous
40 # line of the beginning of the original message.
41 11990 ▶ unless( $readcursor ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($readcursor) 11802 188 11990
42 # Beginning of the bounce message or message/delivery-status part
43 11802 ▶ $readcursor |= $indicators->{'deliverystatus'} if grep { index($e, $_) == 0 } $startingof->{'message'}->@*;
Branch: 1 branch
BranchTrueFalseTotal
if grep {index($e, $_) == 0;} @{$$startingof{"message"}} 36 11766 11802
44 11802 next;
45 }
46 188 ▶ next if ($readcursor & $indicators->{'deliverystatus'}) == 0 || $e eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq "" 51 137 188
Condition66%2/3
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
l!l&&r!l&&!r
051137
MC/DC50%1/2
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
($readcursor & $indicators->{"deliverystatus"}) == 0 $e eq ""
Truth table66%2/3
A or B
A= ($readcursor & $indicators->{"deliverystatus"}) == 0B= $e eq ""
ABresult
1X1
011
000
47  
48 # Message from example.com.
49 # Unable to deliver message to the following address(es).
50 #
51 # <kijitora@example.com>:
52 # This user doesn't have a example.com account (kijitora@example.com) [0]
53 #
54 # --- OR ---
55 #
56 # This Delivery Status Notification is sent from MTA...
57 #
58 # Your delivery to the following address has been failed.
59 # Please refer to the below for details.
60 # ------------------------------------------------------
61 #
62 # Delivery failed: kijitora@example.co.jp
63 # 192.0.2.25 does not like recipient.
64 # Remote host said[Response Message]: 550 5.1.1 <kijitora@example.co.jp>:
65 # Recipient address rejected: User unknown in local recipient table
66 # Giving up on 192.0.2.25.
67 # STEP: RCPT TO
68 137 $v = $dscontents->[-1];
69  
70 137 ▶ if( index($e, '<') == 0 && Sisimai::String->aligned(\$e, ['<', '@', '>:']) ||
Branch: 3 branches
BranchTrueFalseTotal
if (index($e, '<') == 0 and 'Sisimai::String'->aligned(\$e, ['<', '@', '>:']) or index($e, 'Delivery failed: ') == 0 and 'Sisimai::String'->aligned(\$e, ['failed: ', '@'])) { } 46 91 137
elsif (index($e, 'STTEP: ') == 0) { } 0 91 91
elsif (index($e, '-----') != 0) { } 86 5 91
Condition77%7/9
index($e, "<") == 0 and "Sisimai::String"->aligned(\$e, ["<", "\@", ">:"]) or index($e, "Delivery failed: ") == 0 and "Sisimai::String"->aligned(\$e, ["failed: ", "\@"])
l!l&&r!l&&!r
41591
index($e, "<") == 0 and "Sisimai::String"->aligned(\$e, ["<", "\@", ">:"])
!ll&&!rl&&r
96041
index($e, "Delivery failed: ") == 0 and "Sisimai::String"->aligned(\$e, ["failed: ", "\@"])
!ll&&!rl&&r
9105
MC/DC50%2/4
index($e, "<") == 0 and "Sisimai::String"->aligned(\$e, ["<", "\@", ">:"]) or index($e, "Delivery failed: ") == 0 and "Sisimai::String"->aligned(\$e, ["failed: ", "\@"])
index($e, "<") == 0 "Sisimai::String"->aligned(\$e, ["<", "\@", ">:"]) index($e, "Delivery failed: ") == 0 "Sisimai::String"->aligned(\$e, ["failed: ", "\@"])
Truth table42%3/7
A and B or C and D
A= index($e, "<") == 0B= "Sisimai::String"->aligned(\$e, ["<", "\@", ">:"])C= index($e, "Delivery failed: ") == 0D= "Sisimai::String"->aligned(\$e, ["failed: ", "\@"])
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
71 index($e, 'Delivery failed: ') == 0 && Sisimai::String->aligned(\$e, ['failed: ', '@']) ) {
72 # <kijitora@example.com>:
73 # Delivery failed: kijitora@example.co.jp
74 46 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 10 36 46
75 # There are multiple recipient addresses in the message body.
76 10 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
77 10 $v = $dscontents->[-1];
78 }
79 46 ▶ $v->{'recipient'} = substr($e, 1, length($e) - 3 ) if index($e, '<') == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($e, "<") == 0 41 5 46
80 46 ▶ $v->{'recipient'} ||= substr($e, index($e, ': ') + 2,);
Condition66%2/3
$v->{"recipient"} ||= substr($e, index($e, ": ") + 2)
l!l&&r!l&&!r
4150
MC/DC0%0/2
$v->{"recipient"} ||= substr($e, index($e, ": ") + 2)
$v->{"recipient"} substr($e, index($e, ": ") + 2)
Truth table66%2/3
A ||= B
A= $v->{"recipient"}B= substr($e, index($e, ": ") + 2)
ABresult
1X1
011
000
81 46 $recipients++;
82  
83 } elsif( index($e, 'STTEP: ') == 0 ) {
84 # STEP: RCPT TO
85 # STEP: DATA SEND
86 0 $v->{'command'} = Sisimai::SMTP::Command->find($e)
87  
88 } elsif( index($e, '-----') != 0 ) {
89 # This user doesn't have a example.com account (kijitora@example.com) [0]
90 86 $v->{'diagnosis'} .= ' '.$e;
91 }
92 }
93 320 ▶ return undef unless $recipients;
Branch: 1 branch
BranchTrueFalseTotal
unless $recipients 284 36 320
94 36 return {"ds" => $dscontents, "rfc822" => $emailparts->[1]};
95 }
96  
97 37 1;
98 __END__
« Sisimai/Lhost/Gmail.pm ↑ Summary Sisimai/Lhost/MailMarshal.pm »