Sisimai/Lhost/Biglobe.pm

filter: Statementstmt 95.6% 44 / 46 Branchbran 79.1% 19 / 24 Conditioncond 75.0% 9 / 12 MC/DCmcdc 57.1% 4 / 7 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 86.6% 84 / 97 CC 19 SCAR 27.8
CC
19
Cov
88%
inquire
20.1
BEGIN
1.0
BEGIN
1.0
CRAP 16.1
« Sisimai/Lhost/DragonFly.pm ↑ Summary Sisimai/Lhost/MailFoundry.pm »
1 package Sisimai::Lhost::Biglobe;
2 36 ▶use parent 'Sisimai::Lhost';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 36 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 36 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 36 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub description { 'BIGLOBE: https://www.biglobe.ne.jp' }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
8 914 ▶sub inquire {
Subroutine inquire: called CC=19 SCAR=30.0
Pod documented
9 # Detect an error from Biglobe
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.0.0
15 914 my $class = shift;
16 914 ▶ my $mhead = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
9131
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
17 913 ▶ my $mbody = 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
18  
19 912 ▶ return undef unless index($mhead->{'from'}, 'postmaster@') > -1;
Branch: 1 branch
BranchTrueFalseTotal
unless index($mhead->{"from"}, "postmaster\@") != -1 713 199 912
20 199 ▶ return undef unless grep { index($mhead->{'from'}, '@'.$_.'.ne.jp') > -1 } (qw|biglobe inacatv tmtv ttv|);
Branch: 1 branch
BranchTrueFalseTotal
unless grep {index($mhead->{"from"}, '@' . $_ . '.ne.jp') != -1;} "biglobe", "inacatv", "tmtv", "ttv" 193 6 199
21 6 ▶ return undef unless index($mhead->{'subject'}, 'Returned mail:') == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless index($mhead->{"subject"}, "Returned mail:") == 0 0 6 6
22  
23 6 state $indicators = __PACKAGE__->INDICATORS;
24 6 state $boundaries = ['Content-Type: message/rfc822'];
25 6 state $startingof = {
26 'message' => [' ----- The following addresses had delivery problems -----'],
27 'error' => [' ----- Non-delivered information -----'],
28 };
29 6 ▶ my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $emailparts->[0] 0 6 6
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
l!l
60
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 6 my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef;
31 6 my $readcursor = 0; # (Integer) Points the current cursor position
32 6 my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
33  
34 6 for my $e ( split("\n", $emailparts->[0]) ) {
35 # Read error messages and delivery status lines from the head of the email to the previous
36 # line of the beginning of the original message.
37 42 ▶ unless( $readcursor ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($readcursor) 18 24 42
38 # Beginning of the bounce message or message/delivery-status part
39 18 ▶ $readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($e, $startingof->{"message"}[0]) == 0 6 12 18
40 18 next;
41 }
42 24 ▶ next if ($readcursor & $indicators->{'deliverystatus'}) == 0 || $e eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq "" 6 18 24
Condition66%2/3
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
l!l&&r!l&&!r
0618
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
43  
44 # This is a MIME-encapsulated message.
45 #
46 # ----_Biglobe000000/00000.biglobe.ne.jp
47 # Content-Type: text/plain; charset="iso-2022-jp"
48 #
49 # ----- The following addresses had delivery problems -----
50 # ********@***.biglobe.ne.jp
51 #
52 # ----- Non-delivered information -----
53 # The number of messages in recipient's mailbox exceeded the local limit.
54 #
55 # ----_Biglobe000000/00000.biglobe.ne.jp
56 # Content-Type: message/rfc822
57 #
58 18 $v = $dscontents->[-1];
59  
60 18 ▶ if( index($e, '@') > 1 && index($e, ' ') == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($e, '@') > 1 and index($e, ' ') == -1) { } 6 12 18
Condition66%2/3
index($e, "\@") > 1 and index($e, " ") == -1
!ll&&!rl&&r
1206
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
61 # ----- The following addresses had delivery problems -----
62 # ********@***.biglobe.ne.jp
63 6 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 0 6 6
64 # There are multiple recipient addresses in the message body.
65 0 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
66 0 $v = $dscontents->[-1];
67 }
68 6 ▶ next unless Sisimai::Address->is_emailaddress($e);
Branch: 1 branch
BranchTrueFalseTotal
unless "Sisimai::Address"->is_emailaddress($e) 0 6 6
69 6 $v->{'recipient'} = $e;
70 6 $recipients++;
71  
72 } else {
73 12 ▶ next if index($e, '--') > -1;
Branch: 1 branch
BranchTrueFalseTotal
if index($e, "--") != -1 6 6 12
74 6 $v->{'diagnosis'} .= $e.' ';
75 }
76 }
77 6 ▶ return undef unless $recipients;
Branch: 1 branch
BranchTrueFalseTotal
unless $recipients 0 6 6
78 6 return {"ds" => $dscontents, "rfc822" => $emailparts->[1]};
79 }
80  
81 36 1;
82 __END__
« Sisimai/Lhost/DragonFly.pm ↑ Summary Sisimai/Lhost/MailFoundry.pm »