Sisimai/Lhost/X3.pm

filter: Statementstmt 95.7% 45 / 47 Branchbran 87.5% 21 / 24 Conditioncond 75.0% 9 / 12 MC/DCmcdc 57.1% 4 / 7 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 88.7% 87 / 98 CC 19 SCAR 27.5
CC
19
Cov
90%
inquire
19.5
BEGIN
1.0
BEGIN
1.0
CRAP 15.7
« Sisimai/Lhost/GoogleGroups.pm ↑ Summary Sisimai/Lhost/GMX.pm »
1 package Sisimai::Lhost::X3;
2 35 ▶use parent 'Sisimai::Lhost';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 35 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 35 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 35 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub description { 'Unknown MTA #3' }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
8 883 ▶sub inquire {
Subroutine inquire: called CC=19 SCAR=29.7
Pod documented
9 # Detect an error from Unknown MTA #3
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.9
15 883 my $class = shift;
16 883 ▶ my $mhead = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
8821
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
17 882 ▶ my $mbody = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
8811
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
18  
19 881 ▶ return undef unless index($mhead->{'from'}, 'Mail Delivery System') == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless index($mhead->{"from"}, "Mail Delivery System") == 0 836 45 881
20 45 ▶ return undef unless index($mhead->{'subject'}, 'Delivery status notification') == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless index($mhead->{"subject"}, "Delivery status notification") == 0 19 26 45
21  
22 26 require Sisimai::SMTP::Command;
23 26 state $indicators = __PACKAGE__->INDICATORS;
24 26 state $boundaries = ['Content-Type: message/rfc822'];
25 26 state $startingof = {'message' => [' This is an automatically generated Delivery Status Notification.']};
26  
27 26 ▶ my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $emailparts->[0] 0 26 26
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
l!l
260
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
28 26 my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef;
29 26 my $readcursor = 0; # (Integer) Points the current cursor position
30 26 my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
31  
32 26 for my $e ( split("\n", $emailparts->[0]) ) {
33 # Read error messages and delivery status lines from the head of the email to the previous
34 # line of the beginning of the original message.
35 472 ▶ unless( $readcursor ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($readcursor) 94 378 472
36 # Beginning of the bounce message or message/delivery-status part
37 94 ▶ $readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($e, $startingof->{"message"}[0]) == 0 26 68 94
38 94 next;
39 }
40 378 ▶ next if ($readcursor & $indicators->{'deliverystatus'}) == 0 || $e eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq "" 187 191 378
Condition66%2/3
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
l!l&&r!l&&!r
0187191
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
41  
42 # ============================================================================
43 # This is an automatically generated Delivery Status Notification.
44 #
45 # Delivery to the following recipients failed permanently:
46 #
47 # * kijitora@example.com
48 #
49 #
50 # ============================================================================
51 # Technical details:
52 #
53 # SMTP:RCPT host 192.0.2.8: 553 5.3.0 <kijitora@example.com>... No such user here
54 #
55 #
56 # ============================================================================
57 191 $v = $dscontents->[-1];
58  
59 191 ▶ if( index($e, ' * ') > -1 && index($e, '@') > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($e, ' * ') != -1 and index($e, '@') > 1) { } 26 165 191
Condition66%2/3
index($e, " * ") != -1 and index($e, "\@") > 1
!ll&&!rl&&r
165026
MC/DC50%1/2
index($e, " * ") != -1 and index($e, "\@") > 1
index($e, " * ") != -1 index($e, "\@") > 1
Truth table66%2/3
A and B
A= index($e, " * ") != -1B= index($e, "\@") > 1
ABresult
0X0
100
111
60 # * kijitora@example.com
61 26 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 0 26 26
62 # There are multiple recipient addresses in the message body.
63 0 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
64 0 $v = $dscontents->[-1];
65 }
66 26 $v->{'recipient'} = substr($e, index($e, ' * ') + 3,);
67 26 $recipients++;
68  
69 } else {
70 # Detect error message
71 165 ▶ if( index($e, 'SMTP:') == 0 ) {
Branch: 3 branches
BranchTrueFalseTotal
if (index($e, 'SMTP:') == 0) { } 11 154 165
elsif (index($e, 'Routing: ') == 0) { } 5 149 154
elsif (index($e, 'Diagnostic-Code: smtp; ') == 0) { } 5 144 149
72 # SMTP:RCPT host 192.0.2.8: 553 5.3.0 <kijitora@example.com>... No such user here
73 11 $v->{'command'} = Sisimai::SMTP::Command->find($e);
74 11 $v->{'diagnosis'} = $e;
75  
76 } elsif( index($e, 'Routing: ') == 0 ) {
77 # Routing: Could not find a gateway for kijitora@example.co.jp
78 5 $v->{'diagnosis'} = substr($e, 9,);
79  
80 } elsif( index($e, 'Diagnostic-Code: smtp; ') == 0 ) {
81 # Diagnostic-Code: smtp; 552 5.2.2 Over quota
82 5 $v->{'diagnosis'} = substr($e, index($e, ';') + 2,);
83 }
84 }
85 }
86 26 ▶ return undef unless $recipients;
Branch: 1 branch
BranchTrueFalseTotal
unless $recipients 0 26 26
87 26 return {"ds" => $dscontents, "rfc822" => $emailparts->[1]};
88 }
89  
90 35 1;
91 __END__
« Sisimai/Lhost/GoogleGroups.pm ↑ Summary Sisimai/Lhost/GMX.pm »