Sisimai/LDA.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 10 / 10 Conditioncond 87.5% 7 / 8 MC/DCmcdc 60.0% 3 / 5 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 93.6% 59 / 63 CC 11 SCAR 21.2
CC
11
Cov
98%
find
11.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.3
« Sisimai.pm ↑ Summary Sisimai/Fact/YAML.pm »
1 package Sisimai::LDA;
2 87 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 87 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 87 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 87 ▶use Sisimai::Eb;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 87 state $LocalAgent = {
8 # Each error message should be a lower-cased string
9 # dovecot/src/deliver/deliver.c
10 # 11: #define DEFAULT_MAIL_REJECTION_HUMAN_REASON \
11 # 12: "Your message to <%t> was automatically rejected:%n%r"
12 "dovecot" => ["Your message to <", "> was automatically rejected:"],
13 "mail.local" => ["mail.local: "],
14 "procmail" => ["procmail: ", "/procmail "],
15 "maildrop" => ["maildrop: "],
16 "vpopmail" => ["vdelivermail: "],
17 "vmailmgr" => ["vdeliver: "],
18 };
19  
20 87 state $MessagesOf = {
21 # Each error message should be a lower-cased string
22 "dovecot" => {
23 # dovecot/src/deliver/mail-send.c:94
24 $Sisimai::Eb::ReFULL => [
25 "not enough disk space",
26 "quota exceeded", # Dovecot 1.2 dovecot/src/plugins/quota/quota.c
27 "quota exceeded (mailbox for user is full)", # dovecot/src/plugins/quota/quota.c
28 ],
29 $Sisimai::Eb::ReUSER => ["mailbox doesn't exist: "],
30 },
31 "mail.local" => {
32 $Sisimai::Eb::ReFULL => ["disc quota exceeded", "mailbox full or quota exceeded"],
33 $Sisimai::Eb::RePROC => ["temporary file write error"],
34 $Sisimai::Eb::ReUSER => [
35 ": invalid mailbox path",
36 ": unknown user:",
37 ": user missing home directory",
38 ": user unknown",
39 ],
40 },
41 "procmail" => {
42 $Sisimai::Eb::ReFULL => ["quota exceeded while writing", "user over quota"],
43 $Sisimai::Eb::RePROC => ["service unavailable"],
44 $Sisimai::Eb::ReDISK => ["no space left to finish writing"],
45 },
46 "maildrop" => {
47 $Sisimai::Eb::ReFULL => ["maildir over quota."],
48 $Sisimai::Eb::ReUSER => ["invalid user specified.", "cannot find system user"],
49 },
50 "vpopmail" => {
51 $Sisimai::Eb::ReFILT => ["user does not exist, but will deliver to "],
52 $Sisimai::Eb::ReFULL => ["domain is over quota", "user is over quota"],
53 $Sisimai::Eb::ReQUIT => ["account is locked email bounced"],
54 $Sisimai::Eb::ReUSER => ["sorry, no mailbox here by that name."],
55 },
56 "vmailmgr" => {
57 $Sisimai::Eb::ReFULL => ["delivery failed due to system quota violation"],
58 $Sisimai::Eb::ReUSER => [
59 "invalid or unknown base user or domain",
60 "invalid or unknown virtual user",
61 "user name does not refer to a virtual user"
62 ],
63 },
64 };
65  
66 3373 ▶sub find {
Subroutine find: called CC=11 SCAR=24.0
Pod undocumented
67 # Decode the message body and return a bounce reason detected by the error message of LDA
68 # @param [Sisimai::Fact] argvs Decoded email object
69 # @return [String] The value of bounce reason
70 3373 my $class = shift;
71 3373 ▶ my $argvs = shift // return "";
Condition100%2/2
shift() // (return "")
l!l
33721
MC/DC100%1/1
shift() // (return "")
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
72  
73 3372 ▶ return "" unless length $argvs->{"diagnosticcode"};
Branch: 1 branch
BranchTrueFalseTotal
unless length $argvs->{"diagnosticcode"} 10 3362 3372
74 3362 ▶ return "" unless $argvs->{"command"} eq "" || $argvs->{"command"} eq $Sisimai::Eb::CeDATA;
Branch: 1 branch
BranchTrueFalseTotal
unless $argvs->{"command"} eq "" or $argvs->{"command"} eq $Sisimai::Eb::CeDATA 1007 2355 3362
Condition100%3/3
$argvs->{"command"} eq "" or $argvs->{"command"} eq $Sisimai::Eb::CeDATA
l!l&&r!l&&!r
17116441007
MC/DC100%2/2
$argvs->{"command"} eq "" or $argvs->{"command"} eq $Sisimai::Eb::CeDATA
$argvs->{"command"} eq "" $argvs->{"command"} eq $Sisimai::Eb::CeDATA
Truth table100%3/3
A or B
A= $argvs->{"command"} eq ""B= $argvs->{"command"} eq $Sisimai::Eb::CeDATA
ABresult
1X1
011
000
75  
76 2355 my $deliversby = ""; # [String] Local Delivery Agent name
77 2355 my $reasontext = ""; # [String] Detected bounce reason
78 2355 my $issuedcode = lc $argvs->{"diagnosticcode"};
79  
80 2355 for my $e ( keys %$LocalAgent ) {
81 # Find a local delivery agent name from the lower-cased error message
82 14060 ▶ next unless grep { index($issuedcode, $_) > -1 } $LocalAgent->{ $e }->@*;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {index($issuedcode, $_) != -1;} @{$$LocalAgent{$e}} 14023 37 14060
83 37 $deliversby = $e; last;
84 }
85 2355 ▶ return "" unless $deliversby;
Branch: 1 branch
BranchTrueFalseTotal
unless $deliversby 2318 37 2355
86  
87 37 for my $e ( keys $MessagesOf->{ $deliversby }->%* ) {
88 # The key nane is a bounce reason name
89 82 ▶ next unless grep { index($issuedcode, $_) > -1 } $MessagesOf->{ $deliversby }->{ $e }->@*;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {index($issuedcode, $_) != -1;} @{$$MessagesOf{$deliversby}{$e}} 57 25 82
90 25 $reasontext = $e; last;
91 }
92  
93 37 ▶ $reasontext ||= $Sisimai::Eb::ReUNIX; # procmail: Couldn't create "/var/mail/tmp.nekochan.22"
Condition66%2/3
$reasontext ||= $Sisimai::Eb::ReUNIX
l!l&&r!l&&!r
25120
MC/DC0%0/2
$reasontext ||= $Sisimai::Eb::ReUNIX
$reasontext $Sisimai::Eb::ReUNIX
Truth table66%2/3
A ||= B
A= $reasontextB= $Sisimai::Eb::ReUNIX
ABresult
1X1
011
000
94 37 return $reasontext;
95 }
96  
97 87 1;
98 __END__
« Sisimai.pm ↑ Summary Sisimai/Fact/YAML.pm »