Sisimai/Lhost/X1.pm

filter: Statementstmt 94.0% 47 / 50 Branchbran 87.5% 21 / 24 Conditioncond 72.7% 8 / 11 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 87.8% 87 / 99 CC 20 SCAR 28.2
CC
20
Cov
89%
inquire
20.8
BEGIN
1.0
BEGIN
1.0
CRAP 16.8
« Sisimai/Rhost/GSuite.pm ↑ Summary Sisimai/Lhost/DragonFly.pm »
1 package Sisimai::Lhost::X1;
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 #1' }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
8 878 ▶sub inquire {
Subroutine inquire: called CC=20 SCAR=30.3
Pod documented
9 # Detect an error from Unknown MTA #1
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.3
15 878 my $class = shift;
16 878 ▶ my $mhead = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
8771
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
17 877 ▶ my $mbody = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
8761
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
18  
19 876 my $proceedsto = 0;
20 876 ▶ $proceedsto = 1 if index($mhead->{'subject'}, 'Returned Mail: ') == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($mhead->{"subject"}, "Returned Mail: ") == 0 11 865 876
21 876 ▶ $proceedsto = 1 if index($mhead->{'subject'}, 'Mail Delivery Failure') == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($mhead->{"subject"}, "Mail Delivery Failure") == 0 24 852 876
22 876 ▶ $proceedsto = 1 if Sisimai::String->aligned(\$mhead->{'from'}, ['"Mail Deliver', 'System" ']);
Branch: 1 branch
BranchTrueFalseTotal
if "Sisimai::String"->aligned(\$mhead->{"from"}, ["\"Mail Deliver", "System\" "]) 31 845 876
23 876 ▶ return undef unless $proceedsto;
Branch: 1 branch
BranchTrueFalseTotal
unless $proceedsto 826 50 876
24  
25 50 state $indicators = __PACKAGE__->INDICATORS;
26 50 state $boundaries = ['Content-Type: message/rfc822', 'Received: from '];
27 50 state $markingsof = {'message' => ['The original message was received at ']};
28  
29 50 ▶ my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $emailparts->[0] 0 50 50
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
l!l
500
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
30 50 my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef;
31 50 my $readcursor = 0; # (Integer) Points the current cursor position
32 50 my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
33 50 my $datestring = ''; # (String) Date string
34  
35 50 for my $e ( split("\n", $emailparts->[0]) ) {
36 # Read error messages and delivery status lines from the head of the email to the previous
37 # line of the beginning of the original message.
38 1042 ▶ unless( $readcursor ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($readcursor) 894 148 1042
39 # Beginning of the bounce message or message/delivery-status part
40 894 ▶ $readcursor |= $indicators->{'deliverystatus'} if index($e, $markingsof->{'message'}->[0]) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($e, $markingsof->{"message"}[0]) == 0 21 873 894
41 894 next;
42 }
43 148 ▶ next if ($readcursor & $indicators->{'deliverystatus'}) == 0 || $e eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq "" 69 79 148
Condition66%2/3
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
l!l&&r!l&&!r
06979
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
44  
45 # The original message was received at Thu, 29 Apr 2010 23:34:45 +0900 (JST)
46 # from shironeko@example.jp
47 #
48 # ---The following addresses had delivery errors---
49 #
50 # kijitora@example.co.jp [User unknown]
51 79 $v = $dscontents->[-1];
52  
53 79 ▶ if( Sisimai::String->aligned(\$e, ['@', ' [', ']']) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ('Sisimai::String'->aligned(\$e, ['@', ' [', ']'])) { } 21 58 79
elsif (index($e, $markingsof->{'message'}[0]) == 0) { } 0 58 58
54 # kijitora@example.co.jp [User unknown]
55 21 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 0 21 21
56 # There are multiple recipient addresses in the message body.
57 0 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
58 0 $v = $dscontents->[-1];
59 }
60 21 my $p1 = index($e, ' ');
61 21 my $p2 = index($e, ']');
62 21 $v->{'recipient'} = substr($e, 0, $p1);
63 21 $v->{'diagnosis'} = substr($e, $p1 + 2, $p2 - $p1 - 2);
64 21 $recipients++;
65  
66 } elsif( index($e, $markingsof->{'message'}->[0]) == 0 ) {
67 # The original message was received at Thu, 29 Apr 2010 23:34:45 +0900 (JST)
68 0 $datestring = substr($e, length $markingsof->{'message'}->[0],);
69 }
70 }
71 50 ▶ return undef unless $recipients;
Branch: 1 branch
BranchTrueFalseTotal
unless $recipients 29 21 50
72  
73 21 ▶ $_->{'date'} = $datestring || '' for @$dscontents;
Condition50%1/2
$datestring || ''
l!l
021
MC/DC0%0/1
$datestring || ''
$datestring
Truth table50%1/2
A
A= $datestring
Aresult
11
00
74 21 return {"ds" => $dscontents, "rfc822" => $emailparts->[1]};
75 }
76  
77 35 1;
78 __END__
« Sisimai/Rhost/GSuite.pm ↑ Summary Sisimai/Lhost/DragonFly.pm »