Sisimai/Lhost/GoogleGroups.pm

filter: Statementstmt 95.5% 43 / 45 Branchbran 55.5% 10 / 18 Conditioncond 70.0% 7 / 10 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 81.4% 70 / 86 CC 17 SCAR 27.5
CC
17
Cov
82%
inquire
19.9
BEGIN
1.0
BEGIN
1.0
CRAP 15.6
« Sisimai/Lhost/Zoho.pm ↑ Summary Sisimai/Lhost/X3.pm »
1 package Sisimai::Lhost::GoogleGroups;
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 { 'Google Groups: https://groups.google.com' }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
8 964 ▶sub inquire {
Subroutine inquire: called CC=17 SCAR=29.9
Pod documented
9 # Detect an error from Google Groups
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.25.6
15 964 my $class = shift;
16 964 ▶ my $mhead = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
9631
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
17 963 ▶ my $mbody = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
9621
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
18  
19 962 ▶ return undef unless index($$mbody, "Google Group") > -1;
Branch: 1 branch
BranchTrueFalseTotal
unless index($$mbody, "Google Group") != -1 891 71 962
20 71 ▶ return undef unless rindex($mhead->{'from'}, '<mailer-daemon@googlemail.com>') > -1;
Branch: 1 branch
BranchTrueFalseTotal
unless rindex($mhead->{"from"}, "<mailer-daemon\@googlemail.com>") != -1 0 71 71
21 71 ▶ return undef unless index($mhead->{'subject'}, 'Delivery Status Notification') > -1;
Branch: 1 branch
BranchTrueFalseTotal
unless index($mhead->{"subject"}, "Delivery Status Notification") != -1 0 71 71
22 71 ▶ return undef unless exists $mhead->{'x-failed-recipients'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $mhead->{"x-failed-recipients"} 0 71 71
23  
24 # Hello kijitora@libsisimai.org,
25 #
26 # We're writing to let you know that the group you tried to contact (group-name)
27 # may not exist, or you may not have permission to post messages to the group.
28 # A few more details on why you weren't able to post:
29 #
30 # * You might have spelled or formatted the group name incorrectly.
31 # * The owner of the group may have removed this group.
32 # * You may need to join the group before receiving permission to post.
33 # * This group may not be open to posting.
34 #
35 # If you have questions related to this or any other Google Group,
36 # visit the Help Center at https://groups.google.com/support/.
37 #
38 # Thanks,
39 #
40 # Google Groups
41 71 require Sisimai::Eb;
42 71 state $boundaries = ['----- Original message -----', 'Content-Type: message/rfc822'];
43 71 ▶ my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $emailparts->[0] 0 71 71
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
l!l
710
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
44 71 my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = $dscontents->[-1];
45 71 my $recipients = 0;
46 71 my @entiremesg = split(/\n\n/, $emailparts->[0], 5); pop @entiremesg;
47 71 my $issuedcode = join(' ', @entiremesg); $issuedcode =~ y/\n/ /;
48 71 ▶ my $receivedby = $mhead->{'received'} || [];
Condition50%1/2
$mhead->{'received'} || []
l!l
710
MC/DC0%0/1
$mhead->{'received'} || []
$mhead->{'received'}
Truth table50%1/2
A
A= $mhead->{'received'}
Aresult
11
00
49 71 my $recordwide = {
50 'rhost' => Sisimai::RFC5322->received($receivedby->[0])->[1],
51 'reason' => $Sisimai::Eb::Re___1,
52 'diagnosis' => $issuedcode,
53 };
54  
55 # * You might have spelled or formatted the group name incorrectly.
56 # * The owner of the group may have removed this group.
57 # * You may need to join the group before receiving permission to post.
58 # * This group may not be open to posting.
59 71 ▶ my $fewdetails = [$emailparts->[0] =~ /^[ ]?[*][ ]?/gm] || [];
Condition50%1/2
[$emailparts->[0] =~ /^[ ]?[*][ ]?/gmu] || []
l!l
710
MC/DC0%0/1
[$emailparts->[0] =~ /^[ ]?[*][ ]?/gmu] || []
[$emailparts->[0] =~ /^[ ]?[*][ ]?/gmu]
Truth table50%1/2
A
A= [$emailparts->[0] =~ /^[ ]?[*][ ]?/gmu]
Aresult
11
00
60 71 ▶ $recordwide->{'reason'} = $Sisimai::Eb::ReFROM if scalar @$fewdetails == 4;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @$fewdetails == 4 71 0 71
61  
62 71 for my $e ( split(',', $mhead->{'x-failed-recipients'}) ) {
63 # X-Failed-Recipients: neko@example.jp, nyaan@example.org, ...
64 71 ▶ next unless Sisimai::Address->is_emailaddress($e);
Branch: 1 branch
BranchTrueFalseTotal
unless "Sisimai::Address"->is_emailaddress($e) 0 71 71
65  
66 71 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 0 71 71
67 # There are multiple recipient addresses in the message body.
68 0 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
69 0 $v = $dscontents->[-1];
70 }
71 71 $v->{'recipient'} = Sisimai::Address->s3s4($e);
72 71 $recipients++;
73 71 $v->{ $_ } = $recordwide->{ $_ } for keys %$recordwide;
74 }
75 71 ▶ return undef unless $recipients;
Branch: 1 branch
BranchTrueFalseTotal
unless $recipients 0 71 71
76 71 return {"ds" => $dscontents, "rfc822" => $emailparts->[1]};
77 }
78  
79 37 1;
80 __END__
« Sisimai/Lhost/Zoho.pm ↑ Summary Sisimai/Lhost/X3.pm »