Box/Message.pm

filter: Statementstmt 92.4% 61 / 66 Branchbran 72.7% 16 / 22 Conditioncond 46.6% 7 / 15 MC/DCmcdc 11.1% 1 / 9 Subroutinesub 94.1% 16 / 17 Podpod 80.0% 8 / 10 totaltotal 78.4% 109 / 139 CC 17 SCAR 17.8
CC
17
Cov
82%
moveTo
12.0
head
11.8
readBody
3.1
CRAP 5.9
« Box/Locker/Flock.pm ↑ Summary Box/Locker/POSIX.pm »
1 # This code is part of Perl distribution Mail-Box version 4.02.
2 # The POD got stripped from this file by OODoc version 3.06.
3 # For contributors see file ChangeLog.
4  
5 # This software is copyright (c) 2001-2026 by Mark Overmeer.
6  
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10  
11  
12 package Mail::Box::Message;{
13 34 our $VERSION = '4.02';
14 }
15  
16 34 ▶use parent 'Mail::Message';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 34 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 34 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 34 ▶use Log::Report 'mail-box', import => [ qw// ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 34 ▶use Scalar::Util qw/weaken/;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 34 ▶use Mail::Box::Message::Destructed ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 #--------------------
28  
29 sub init($)
30 2041 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
31 2041 $self->SUPER::init($args);
32  
33 2041 $self->{MBM_body_type} = $args->{body_type};
34 2041 $self->{MBM_folder} = $args->{folder};
35 2041 weaken($self->{MBM_folder});
36  
37 2041 $self;
38 }
39  
40 sub head(;$)
41 20692 ▶{ my $self = shift;
Subroutine head: called CC=11 SCAR=24.7
Pod documented
42 20692 ▶ @_ or return $self->SUPER::head;
Branch: 1 branch
BranchTrueFalseTotal
@_ or return $self->SUPER::head 2337 18355 20692
43  
44 2337 my $new = shift;
45 2337 my $old = $self->head;
46 2337 $self->SUPER::head($new);
47  
48 2337 ▶ defined $new || defined $old
Branch: 1 branch
BranchTrueFalseTotal
defined $new or defined $old or return undef 2337 0 2337
Condition66%2/3
defined $new or defined $old
l!l&&r!l&&!r
2282550
MC/DC0%0/2
defined $new or defined $old
defined $new defined $old
Truth table66%2/3
A or B
A= defined $newB= defined $old
ABresult
1X1
011
000
49 or return undef;
50  
51 2337 ▶ my $folder = $self->folder
Branch: 1 branch
BranchTrueFalseTotal
my $folder = $self->folder or return $new 1600 737 2337
52 or return $new;
53  
54 1600 ▶ if(!defined $new && defined $old && !$old->isDelayed)
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $new and defined $old and not $old->isDelayed) { } 55 1545 1600
elsif (defined $new and not $new->isDelayed) { } 1545 0 1545
Condition66%4/6
not defined $new and defined $old and not $old->isDelayed
!ll&&!rl&&r
1545055
not defined $new and defined $old
!ll&&!rl&&r
1545055
MC/DC33%1/3
not defined $new and defined $old and not $old->isDelayed
not defined $new defined $old not $old->isDelayed
Truth table50%2/4
not(A) and B and not(C)
A= not defined $newB= defined $oldC= not $old->isDelayed
ABCresult
0XX0
10X0
1100
1111
55 55 { $folder->messageId($self->messageId, undef);
56 55 $folder->toBeUnthreaded($self);
57 }
58 ▶ elsif(defined $new && !$new->isDelayed)
Condition33%1/3
defined $new and not $new->isDelayed
!ll&&!rl&&r
001545
MC/DC0%0/2
defined $new and not $new->isDelayed
defined $new not $new->isDelayed
Truth table33%1/3
A and not(B)
A= defined $newB= not $new->isDelayed
ABresult
0X0
100
111
59 1545 { $folder->messageId($self->messageId, $self);
60 1545 $folder->toBeThreaded($self);
61 }
62  
63 1600 ▶ $new || $old;
Branch: 1 branch
BranchTrueFalseTotal
$new or $old 1545 55 1600
64 }
65  
66 #--------------------
67  
68 sub folder(;$)
69 4416 ▶{ my $self = shift;
Subroutine folder: called CC=2 SCAR=6.9
Pod documented
70 4416 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 142 4274 4416
71 142 { $self->{MBM_folder} = shift;
72 142 weaken($self->{MBM_folder});
73 142 $self->modified(1);
74 }
75 4416 $self->{MBM_folder};
76 }
77  
78  
79 2420 ▶sub seqnr(;$) { my $self = shift; @_ ? $self->{MBM_seqnr} = shift : $self->{MBM_seqnr} }
Subroutine seqnr: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2138 282 2420
80  
81 #--------------------
82  
83 sub copyTo($@)
84 129 ▶{ my ($self, $folder) = (shift, shift);
Subroutine copyTo: called CC=1 SCAR=0.0
Pod documented
85 129 $folder->addMessage($self->clone(@_));
86 }
87  
88  
89 sub moveTo($@)
90 0 ▶{ my ($self, $folder, %args) = @_;
Subroutine moveTo: not called CC=3 SCAR=24.8
Pod documented
91  
92 exists $args{share} || exists $args{shallow_body}
93 0 ▶ or $args{share} = 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{"share"} or exists $args{"shallow_body"} or $args{"share"} = 1 0 0 0
Condition0%0/3
exists $args{"share"} or exists $args{"shallow_body"}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $args{"share"} or exists $args{"shallow_body"}
exists $args{"share"} exists $args{"shallow_body"}
Truth table0%0/3
A or B
A= exists $args{"share"}B= exists $args{"shallow_body"}
ABresult
1X1
011
000
94  
95 0 my $added = $self->copyTo($folder, %args);
96 0 $self->label(deleted => 1);
97 0 $added;
98 }
99  
100 #--------------------
101  
102 sub readBody($$;$)
103 1574 ▶{ my ($self, $parser, $head, $getbodytype) = @_;
Subroutine readBody: called CC=3 SCAR=11.2
Pod documented
104  
105 1574 ▶ unless($getbodytype)
Branch: 1 branch
BranchTrueFalseTotal
unless ($getbodytype) 1574 0 1574
106 1574 { my $folder = $self->folder;
107 1574 ▶ $getbodytype = sub { $folder->determineBodyType(@_) } if defined $folder;
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
if defined $folder 1574 0 1574
108 }
109  
110 1574 $self->SUPER::readBody($parser, $head, $getbodytype);
111 }
112  
113  
114 28 ▶sub diskDelete() { $_[0] }
Subroutine diskDelete: called CC=1 SCAR=0.0
Pod documented
115  
116 1 ▶sub forceLoad() { # compatibility
Subroutine forceLoad: called CC=1 SCAR=0.0
Pod undocumented
117 1 my $self = shift;
118 1 $self->loadBody(@_);
119 1 $self;
120 }
121  
122 #--------------------
123  
124 55 ▶sub destruct() { Mail::Box::Message::Destructed->coerce(shift) }
Subroutine destruct: called CC=1 SCAR=0.0
Pod documented
125  
126 34 1;
« Box/Locker/Flock.pm ↑ Summary Box/Locker/POSIX.pm »