Branch Coverage

blib/lib/Mail/SpamAssassin/PerMsgStatus.pm
Criterion Covered Total %
branch 246 510 48.2


line true false branch
115 0 0 if $conf->{'update_version'}
116 0 0 if @fnames > 1
123 38 0 unless $pms->{'conf'}{'report_hostname'}
128 0 0 unless $pms->{'tag_data'}{'REMOTEHOSTNAME'}
133 0 0 unless $pms->{'tag_data'}{'REMOTEHOSTADDR'}
139 0 0 $lasthop ? :
145 0 0 $lasthop ? :
151 0 0 $lasthop ? :
162 0 0 defined $pms->{'bayes_score'} ? :
171 0 34 if $length > 50
173 2 32 $length > 0 ? :
189 32 2 unless join $arg, sort(@{$pms->{'test_names_hit'};})
195 0 0 unless join $arg, sort(@{$pms->{'subtest_names_hit'};})
203 0 0 unless join $arg, map(($_ . '=' . ($scores->{$_} || '0')), sort(@{$pms->{'test_names_hit'};}))
219 0 0 unless $hdr
241 0 0 $pms->{'is_spam'} ? :
275 142 0 if $self->{'master_deadline'}
277 49 0 if (defined $opts and $opts->{'disable_auto_learning'})
282 0 142 if ($self->{'main'}{'save_pattern_hits'})
289 0 142 if ($dbgcache or $self->{'save_pattern_hits'})
325 0 97 if (not $master_deadline) { }
330 0 96 if (&Mail::SpamAssassin::PerMsgStatus::time() > $master_deadline and not $self->{'deadline_exceeded'})
349 291 0 if $netset
370 0 0 if (($set & 2) == 0 and $self->{'main'}{'bayes_scanner'} and $self->{'main'}{'bayes_scanner'}->is_scan_available and $self->{'conf'}{'use_bayes_rules'})
377 1 96 unless ($self->{'main'}->call_plugins('check_main', {'permsgstatus', $self}))
380 1 0 unless ($self->{'main'}->have_plugin('check_main'))
426 0 96 if (not $master_deadline) { }
431 0 96 if (&Mail::SpamAssassin::PerMsgStatus::time() > $master_deadline and not $self->{'deadline_exceeded'})
441 84 12 if (not $self->{'conf'}{'bayes_auto_learn'} && $self->{'conf'}{'use_bayes'} or $self->{'disable_auto_learning'})
459 0 12 if (defined $force_autolearn and $force_autolearn > 0) { }
461 0 0 if (defined $force_autolearn_names)
468 10 2 unless (defined $isspam)
487 0 2 if ($learnstatus->did_learn)
488 0 0 $isspam ? :
494 2 0 if (exists $self->{'main'}{'bayes_scanner'})
498 0 2 unless (eval { do { my $learnstatus = $self->{'main'}->learn($self->{'msg'}, undef, $isspam, 0); if ($learnstatus->did_learn) { $self->{'auto_learn_status'} = $isspam ? 'spam' : 'ham'; } ; $learnstatus->finish; $self->{'main'}->finish_learner; if (exists $self->{'main'}{'bayes_scanner'}) { $self->{'main'}{'bayes_scanner'}->force_close; } ; 1 } })
499 0 0 $@ ne '' ? :
505 0 2 if (defined $eval_stat)
600 0 12 if (defined $names) { }
613 60 12 if exists $self->{'autolearn_points'}
623 12 0 if (($orig_scoreset & 2) == 0) { }
645 6 13 if (exists $tflags->{$test})
646 1 5 if $tflags->{$test} =~ /\bnoautolearn\b/
647 5 0 if $tflags->{$test} =~ /\buserconf\b/
651 0 0 if ($tflags->{$test} =~ /\blearn\b/)
658 0 0 if ($tflags->{$test} =~ /\bautolearn_force\b/)
666 0 13 unless $scores->{$test}
670 9 4 if ($self->{'conf'}->maybe_header_only($test)) { }
4 0 elsif ($self->{'conf'}->maybe_body_only($test)) { }
833 2 32 if (defined $self->{'auto_learn_force_status'})
855 4 0 unless (exists $self->{'report'})
976 2 32 if ($self->{'is_spam'} and $self->{'conf'}{'report_safe'}) { }
992 0 36 if ($self->{'msg'}{'line_ending'} ne "\n")
1027 0 2 if ($self->{'conf'}{'report_charset'})
1037 0 2 unless ($] < 5.008 or utf8::downgrade($report, 1))
1053 0 2 if (defined $self->{'conf'}{'rewrite_header'}{'Subject'})
1054 0 0 unless defined $subject
1060 0 2 if (defined $self->{'conf'}{'rewrite_header'}{'To'})
1061 0 0 unless defined $to
1067 0 2 if (defined $self->{'conf'}{'rewrite_header'}{'From'})
1068 0 0 unless defined $from
1075 2 0 if defined $from
1076 2 0 if defined $to
1077 0 2 if defined $cc
1078 2 0 if defined $subject
1079 2 0 if defined $date
1080 2 0 if defined $msgid
1083 2 0 if (defined $self->{'conf'}{'report_safe_copy_headers'})
1087 0 0 if exists $already_added{lc $hdr}
1091 0 0 if (lc $hdr eq 'received') { }
1127 2 0 if (defined $ct and $ct ne '' and not $ct =~ m[text/plain]i) { }
1137 0 2 if $self->{'conf'}{'report_safe'} > 1
1189 120 0 unless $pristine_headers[$line] =~ /^X-Spam-(?!Prev-)/i
1194 32 0 if (@pristine_headers and $pristine_headers[$#pristine_headers] =~ /^\s*$/)
1200 0 32 if ($self->{'is_spam'})
1206 0 0 if (not defined $subject and $self->{'is_spam'} and exists $self->{'conf'}{'rewrite_header'}{'Subject'})
1216 0 0 unless /^(From|Subject|To):/i
1218 0 0 unless defined $self->{'conf'}{'rewrite_header'}{$hdr}
1221 0 0 if ($created_subject) { }
1232 0 0 if $hdr =~ /^(?:From|To)$/
1252 0 32 if (@pristine_headers and $pristine_headers[0] =~ /^Return-Path:/i)
1271 168 0 unless $text =~ tr/\000-\177/\200-\377/c
1274 0 0 if ($self->{'report_charset'})
1298 168 0 if ($self->{'conf'}{'fold_headers'}) { }
1299 0 168 if ($hdr_data =~ /\n/) { }
1328 0 430 if ($tag =~ /^ADDEDHEADER(?:HAM|SPAM|)\z/) { }
1333 0 430 if ref $result eq 'ARRAY'
1335 430 0 defined $result ? :
1358 0 0 unless ref $code eq 'CODE'
1362 0 0 !ref($tags) ? :
1380 0 0 if (@blocking_tags) { }
1404 0 658 if (would_log('dbg', 'check'))
1406 0 0 ref $tag_val ne 'ARRAY' ? :
0 0 !defined($tag_val) ? :
1411 0 658 if (ref $self->{'tagrun_actions'}{$tag})
1414 0 0 if ($action_pending)
1416 0 0 if ($self->{'tagrun_tagscnt'}[$action_ind] <= 0) { }
0 0 elsif (not --$self->{'tagrun_tagscnt'}[$action_ind]) { }
1438 98 26 if ref $self->{'tagrun_actions'}
1442 0 0 if @pending_actions
1502 0 9 unless defined $tag
1505 3 6 if (exists $common_tags{$tag}) { }
6 0 elsif (exists $self->{'tag_data'}{$tag}) { }
1508 3 0 if ref $data eq 'CODE'
1509 0 3 if ref $data eq 'ARRAY'
1510 0 3 unless defined $data
1514 0 6 if ref $data eq 'CODE'
1515 0 6 if ref $data eq 'ARRAY'
1516 6 0 unless defined $data
1531 0 430 unless defined $tag
1533 362 68 if (exists $common_tags{$tag}) { }
68 0 elsif (exists $self->{'tag_data'}{$tag}) { }
1536 362 0 if ref $data eq 'CODE'
1537 0 362 unless defined $data
1541 0 68 if ref $data eq 'CODE'
1542 0 68 unless defined $data
1592 0 36 if defined $arg
1593 0 4 defined $arg_spam ? :
0 32 defined $arg_ham ? :
4 32 $self->{'is_spam'} ? :
1608 0 38 if (defined $pad and $pad =~ /^(0+| +)$/)
1610 0 0 if $count > 0
1652 0 0 if (defined &{$method;})
1703 1 95 if (defined $addr and $addr =~ /\@([^\@. \t]+\.[^@ \t]+?)[ \t]*\z/s)
1710 57 39 if (defined $addr and $addr =~ /\@([^\@. \t]+\.[^@ \t]+?)[ \t]*\z/s)
1720 14 82 if ($lasthop)
1726 95 1 unless (defined $self->{'msg'}{'metadata'}{'html'})
1882 596 2772 if (index($request, ':') >= 0)
1885 12 584 if ($1 eq 'raw') { }
584 0 elsif ($1 eq 'addr') { }
0 0 elsif ($1 eq 'name') { }
1893 11 3357 if ($request eq 'ALL') { }
0 3357 elsif ($request eq 'ALL-TRUSTED') { }
0 3357 elsif ($request eq 'ALL-INTERNAL') { }
0 3357 elsif ($request eq 'ALL-UNTRUSTED') { }
0 3357 elsif ($request eq 'ALL-EXTERNAL') { }
110 3247 elsif ($request_lc eq 'envelopefrom') { }
0 3247 elsif ($request_lc eq 'x-spam-relays-untrusted') { }
0 3247 elsif ($request_lc eq 'x-spam-relays-trusted') { }
0 3247 elsif ($request_lc eq 'x-spam-relays-external') { }
0 3247 elsif ($request_lc eq 'x-spam-relays-internal') { }
77 3170 elsif ($request_lc eq 'tocc') { }
77 3093 elsif ($request eq 'MESSAGEID') { }
1895 11 0 $getraw ? :
1945 5 72 if ($result ne '')
1947 5 0 if $result =~ /\S/
1950 72 5 if $result eq ''
1955 38 0 if defined $_
1964 475 2618 $getraw ? :
1967 330 2763 if (@results) { }
1975 132 302 if (defined $result and $getaddr || $getname)
1982 132 0 if ($getaddr) { }
0 0 elsif ($getname) { }
1996 131 1 unless ($result =~ /^".*"$/)
2019 0 0 if ($result =~ /^ \s* (.*?) \s* < [^<>]* >/sx) { }
0 0 elsif ($result =~ /^ [^(,]*? \( (.*?) \) /sx) { }
2046 526 3368 if (exists $$cache{$_[1]}) { }
2059 786 2434 @_ > 2 ? :
674 3220 defined $found ? :
2096 0 130 if $self->{'tbirdurire'}
2144 0 130 if (defined $self->{'uri_list'})
2153 1253 0 if ($info->{'cleaned'})
2214 1257 130 if (defined $self->{'uri_detail_list'})
2234 130 0 if ($self->{'conf'}{'parse_dkim_uris'})
2247 0 130 if $self->{'msg'}{'metadata'}{'html'}{'uri_truncated'}
2259 111 63 if (defined $host and $host ne '' and not $info->{'hosts'}{$host})
2262 111 0 if (defined $domain and $domain ne '' and not $info->{'domains'}{$domain})
2269 0 127 if (would_log('dbg', 'uri') == 2)
2274 0 0 if ($info->{'hosts'} and $info->{'domains'})
2289 1126 0 unless (exists $info->{'cleaned'})
2290 1126 0 if ($type eq 'parsed') { }
2300 1126 304 if (defined $host and $host ne '' and not $info->{'hosts'}{$host})
2303 1126 0 if (defined $domain and $domain ne '' and not $info->{'domains'}{$domain})
2311 0 1126 if (would_log('dbg', 'uri') == 2)
2316 0 0 if ($info->{'hosts'} and $info->{'domains'})
2334 130 0 unless (defined $self->{'parsed_uri_list'})
2365 2 829 if $rawuri =~ m[^(?:(?:https?|ftp|mailto):(?://)?)?[a-z\d.-]*\.\.]i
2373 664 165 unless ($uri =~ /^(?:https?|ftp|mailto|javascript|file):/i)
2374 1 663 if ($uri =~ /^ftp\./i) { }
316 347 elsif ($uri =~ /^www\d{0,2}\./i) { }
34 313 elsif ($uri =~ /\@/) { }
2390 39 790 if ($uri =~ /^mailto:/i)
2392 0 39 if $uri =~ /\%(?:2[1-9a-fA-F]|[3-6][0-9a-fA-F]|7[0-9a-eA-E])/
2393 2 37 unless $uri =~ /^[^\@]+\@[^\@]+$/
2395 2 35 unless $domuri
2397 32 3 unless $rawuri eq $uri
2400 35 790 unless $uri =~ /^(?:https?|ftp):/i
2406 777 23 if ($domain)
2408 312 465 if ($rblonly)
2416 16 774 unless $goodurifound
2417 462 312 unless $rblonly
2423 0 1306 if (length $uri > 8192)
2445 0 0 if $self->is_rule_complete($r)
2454 0 0 if (not $self->is_rule_complete($r)) { }
0 0 elsif ($elapsed > 0) { }
2476 0 3281 unless ($function)
2482 3061 220 if exists $TEMPORARY_EVAL_GLUE_METHODS{$function}
2486 0 220 unless exists $self->{'conf'}{'eval_plugins'}{$function}
2490 0 220 if $self->can($function) and defined &{'Mail::SpamAssassin::PerMsgStatus::' . $function;}
2506 0 220 unless (eval $evalstr . '; 1')
2507 0 0 $@ ne '' ? :
2551 76 86 if ($rule =~ /^__/)
2554 0 86 unless (defined $score)
2560 0 86 if ($score != $score)
2571 1 85 if ($score >= 10 or $score <= -10) { }
2585 34 52 $self->{'test_log_msgs'}{'TERSE'} ? :
2669 0 170 if (defined $score) { }
2673 0 170 unless defined $score
2678 0 170 unless ($score)
2686 164 6 if (not $value or $value <= 0)
2690 0 170 if (defined $tflags_add and $tflags_add ne '')
2692 0 0 !defined($_) || $_ eq '' ? :
2697 8 162 if ($already_hit and not +($tflags_ref->{$rule} || '') =~ /\bmultiple\b/)
2707 0 162 if ($dynamic_score_provided)
2713 0 162 if (defined $rule_descr) { }
2720 110 52 if not defined $rule_descr or $rule_descr eq ''
2730 0 162 if ($dups and @{$dups;})
2756 0 45 if (length $msg > 47) { }
2781 0 110 if (defined $self->{'conf'}{'envelope_sender_header'})
2785 0 0 if defined $envf and $envf =~ /\@/ || $envf eq ''
2787 0 0 if (defined $envf) { }
2805 102 8 unless (defined $lasthop)
2811 33 77 if (defined $lasthop)
2815 0 33 if ($envf and $envf =~ /\@/)
2828 0 110 if ($self->get('X-Sender') =~ /\@/)
2830 0 0 if ($rcvd =~ /\(fetchmail/)
2837 0 110 if ($envf = $self->get('X-Envelope-From'))
2840 0 0 if ($self->get('ALL:raw') =~ /^Received:.*^X-Envelope-From:/ism) { }
2849 0 110 if ($envf = $self->get('Envelope-Sender'))
2852 0 0 if ($self->get('ALL:raw') =~ /^Received:.*^Envelope-Sender:/ism) { }
2866 11 99 if ($envf = $self->get('Return-Path'))
2869 0 11 if ($self->get('ALL:raw') =~ /^Received:.*^Return-Path:/ism) { }
2903 0 0 if defined $end_rcvd and $end_rcvd < 0
2905 0 0 unless defined $include_start_rcvd
2906 0 0 unless defined $include_end_rcvd
2912 0 0 if ($hdr =~ /^Received:/i)
2914 0 0 if defined $start_rcvd and not $include_start_rcvd and $start_rcvd == $cur_rcvd_index
2916 0 0 if defined $end_rcvd and not $include_end_rcvd and $end_rcvd == $cur_rcvd_index
2919 0 0 if (!defined($start_rcvd) || $start_rcvd <= $cur_rcvd_index and !defined($end_rcvd) || $cur_rcvd_index < $end_rcvd) { }
0 0 elsif (defined $end_rcvd and $cur_rcvd_index == $end_rcvd) { }
2928 0 0 $result eq '' ? :
2954 0 0 if (defined $self->{'fulltext_tmpfile'})
2959 0 0 unless $tmpfh
2969 0 0 unless defined $nwrites
2971 0 0 unless close $tmpfh
2990 0 237 if (defined $self->{'fulltext_tmpfile'})
2991 0 0 unless (unlink $self->{'fulltext_tmpfile'})
2994 0 0 if ($! == 2) { }
3005 154 91 if (exists $self->{'all_from_addrs'})
3011 0 91 if (defined $resent and $resent =~ /\S/) { }
3052 0 0 if (exists $self->{'all_from_addrs_domains'})
3067 0 0 if not defined $domain or $addrs_seen{lc $domain}++
3082 77 91 if (exists $self->{'all_to_addrs'})
3088 0 91 if ($resent =~ /\S/) { }
3103 22 51 if ($line =~ / for (\S+\@\S+);/)