Mail/Qmail/Filter/CheckDeliverability.pm

filter: Statementstmt 24.0% 13 / 54 Branchbran 0.0% 0 / 36 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 60.0% 3 / 5 Podpod 100% 1 / 1 totaltotal 13.8% 17 / 123 CC 24 SCAR 61.2
CC
24
Cov
12%
filter
552.0
__ANON__
6.0
BEGIN
1.0
CRAP 454.0
↑ Summary Mail/Qmail/Filter/SkipQueue.pm »
1 1 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Mail::Qmail::Filter::CheckDeliverability;
5  
6 1 our $VERSION = '1.02';
7  
8 1 ▶use Mo qw(coerce default);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 extends 'Mail::Qmail::Filter';
10  
11 1 has 'reject_text' => 'Recipient unknown.';
12 1 has 'run_commands_matching';
13  
14 0 ▶sub filter {
Subroutine filter: not called CC=23 SCAR=63.1
Pod documented
15 0 my $self = shift;
16 0 my $message = $self->message;
17 0 my $run_commands_matching = $self->run_commands_matching;
18  
19 0 ▶ require Qmail::Deliverable and Qmail::Deliverable->import('dot_qmail')
Branch: 1 branch
BranchTrueFalseTotal
unless defined &Mail::Qmail::Filter::CheckDeliverability::dot_qmail 0 0 0
Condition0%0/6
defined &Mail::Qmail::Filter::CheckDeliverability::dot_qmail || require Qmail::Deliverable && 'Qmail::Deliverable'->import('dot_qmail')
l!l&&r!l&&!r
000
require Qmail::Deliverable and "Qmail::Deliverable"->import("dot_qmail")
!ll&&!rl&&r
000
MC/DC0%0/3
defined &Mail::Qmail::Filter::CheckDeliverability::dot_qmail || require Qmail::Deliverable && 'Qmail::Deliverable'->import('dot_qmail')
defined &Mail::Qmail::Filter::CheckDeliverability::dot_qmail require Qmail::Deliverable "Qmail::Deliverable"->import("dot_qmail")
Truth table0%0/4
A || B and C
A= defined &Mail::Qmail::Filter::CheckDeliverability::dot_qmailB= require Qmail::DeliverableC= "Qmail::Deliverable"->import("dot_qmail")
ABCresult
1XX1
0111
00X0
0100
20 unless defined &dot_qmail;
21  
22 0 my ( %done, $reject_text, $valid );
23 0 Recipient: for ( $message->to ) {
24 0 my $dot_qmail = dot_qmail($_);
25 0 ▶ unless ( defined $dot_qmail ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $dot_qmail) 0 0 0
26 0 $self->debug( 'No .qmail file found for rcpt' => $_ );
27 0 $reject_text = $self->reject_text;
28 0 next;
29 }
30 0 ▶ next if $done{$dot_qmail}++;
Branch: 1 branch
BranchTrueFalseTotal
if $done{$dot_qmail}++ 0 0 0
31 0 ▶ open my $fh, '<', $dot_qmail
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $dot_qmail or return $self->debug("Cannot read $dot_qmail", $!) 0 0 0
32 or return $self->debug( "Cannot read $dot_qmail", $! );
33 0 $self->debug( "Checking .qmail for $_" => $dot_qmail );
34 0 ▶ while ( defined( my $line = <$fh> ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 0 0 0
35  
36 0 ▶ next if $line =~ /^#/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^#/u 0 0 0
37 0 ++$valid;
38 0 chomp $line;
39 0 ▶ return $self->debug( "$_ is at least deliverable to" => $line )
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ m[^[&/\w]]u 0 0 0
40 if $line =~ m{^[&/\w]};
41 next
42 0 ▶ unless $line =~ /^\|/
Branch: 1 branch
BranchTrueFalseTotal
unless $line =~ /^\|/u and defined $run_commands_matching and $line =~ /$run_commands_matching/u 0 0 0
Condition0%0/6
$line =~ /^\|/u and defined $run_commands_matching and $line =~ /$run_commands_matching/u
!ll&&!rl&&r
000
$line =~ /^\|/u and defined $run_commands_matching
!ll&&!rl&&r
000
MC/DC0%0/3
$line =~ /^\|/u and defined $run_commands_matching and $line =~ /$run_commands_matching/u
$line =~ /^\|/u defined $run_commands_matching $line =~ /$run_commands_matching/u
Truth table0%0/4
A and B and C
A= $line =~ /^\|/uB= defined $run_commands_matchingC= $line =~ /$run_commands_matching/u
ABCresult
0XX0
10X0
1100
1111
43 && defined $run_commands_matching
44 && $line =~ $run_commands_matching;
45  
46 require Capture::Tiny
47 0 ▶ and Capture::Tiny->import('capture_merged')
Branch: 1 branch
BranchTrueFalseTotal
unless defined &Mail::Qmail::Filter::CheckDeliverability::capture_merged 0 0 0
Condition0%0/6
defined &Mail::Qmail::Filter::CheckDeliverability::capture_merged || require Capture::Tiny && 'Capture::Tiny'->import('capture_merged')
l!l&&r!l&&!r
000
require Capture::Tiny and "Capture::Tiny"->import("capture_merged")
!ll&&!rl&&r
000
MC/DC0%0/3
defined &Mail::Qmail::Filter::CheckDeliverability::capture_merged || require Capture::Tiny && 'Capture::Tiny'->import('capture_merged')
defined &Mail::Qmail::Filter::CheckDeliverability::capture_merged require Capture::Tiny "Capture::Tiny"->import("capture_merged")
Truth table0%0/4
A || B and C
A= defined &Mail::Qmail::Filter::CheckDeliverability::capture_mergedB= require Capture::TinyC= "Capture::Tiny"->import("capture_merged")
ABCresult
1XX1
0111
00X0
0100
48 unless defined &capture_merged;
49 0 local $ENV{SENDER} = $message->from;
50 my ( $output, $exitcode ) = capture_merged(
51 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
52 0 ▶ open my $fh, $line
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, $line or return $self->debug("Cannot start $line", $!) 0 0 0
53 or return $self->debug( "Cannot start $line", $! );
54 0 print $fh $message->body;
55 0 close $fh;
56 0 $?;
57 }
58 0 );
59 0 $output = join '/', split /\n/, $output;
60 0 $exitcode >>= 8;
61 0 $self->debug( qq("$line") => $exitcode );
62 0 ▶ last if $exitcode == 99;
Branch: 1 branch
BranchTrueFalseTotal
if $exitcode == 99 0 0 0
63 0 ▶ return $self->debug("Calling $line for $_ resulted in soft failure")
Branch: 1 branch
BranchTrueFalseTotal
if $exitcode == 111 0 0 0
64 if $exitcode == 111;
65 0 ▶ next unless $exitcode == 100;
Branch: 1 branch
BranchTrueFalseTotal
unless $exitcode == 100 0 0 0
66 0 ▶ unless ( defined $reject_text ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $reject_text) { } 0 0 0
if (do { $output ne $reject_text }) 0 0 0
67 0 $reject_text = $output;
68 }
69 0 elsif ( $output ne $reject_text ) {
70 0 return $self->debug(
71 qq(Different reject texts: "$reject_text" vs. "$output"));
72 }
73 0 next Recipient;
74 }
75 0 ▶ return $self->debug("might be deliverable to <$_>") if $valid;
Branch: 1 branch
BranchTrueFalseTotal
if $valid 0 0 0
76 }
77  
78 0 ▶ $self->reject($reject_text) if defined $reject_text;
Branch: 1 branch
BranchTrueFalseTotal
if defined $reject_text 0 0 0
79 0 ▶ $self->reject( $self->reject_text ) unless $valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $valid 0 0 0
80 }
81  
82 1 1;
83  
84 __END__
↑ Summary Mail/Qmail/Filter/SkipQueue.pm »