Branch Coverage

blib/lib/Mail/SpamAssassin/PerMsgStatus.pm
Criterion Covered Total %
branch 284 560 50.7


line true false branch
115 0 0 if $conf->{'update_version'}
116 0 0 if @fnames > 1
123 39 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'};})
202 0 0 unless join $arg, sort(@subtests)
210 0 0 unless join $arg, map(($_ . "=" . ($scores->{$_} || '0')), sort(@{$pms->{'test_names_hit'};}))
225 0 0 unless $pms->{'tag_data'}{'SUBJPREFIX'}
231 0 0 unless $hdr
253 0 0 $pms->{'is_spam'} ? :
288 155 0 if $self->{'master_deadline'}
290 49 0 if (defined $opts and $opts->{'disable_auto_learning'})
295 0 155 if ($self->{'main'}{'save_pattern_hits'})
302 0 155 if ($dbgcache or $self->{'save_pattern_hits'})
338 0 97 if (not $master_deadline) { }
343 0 96 if (&Mail::SpamAssassin::PerMsgStatus::time() > $master_deadline and not $self->{'deadline_exceeded'})
362 291 0 if $netset
383 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'})
390 1 96 unless ($self->{'main'}->call_plugins("check_main", {"permsgstatus", $self}))
393 1 0 unless ($self->{'main'}->have_plugin("check_main"))
439 0 96 if (not $master_deadline) { }
444 0 96 if (&Mail::SpamAssassin::PerMsgStatus::time() > $master_deadline and not $self->{'deadline_exceeded'})
454 84 12 if (not $self->{'conf'}{'bayes_auto_learn'} && $self->{'conf'}{'use_bayes'} or $self->{'disable_auto_learning'})
472 0 12 if (defined $force_autolearn and $force_autolearn > 0) { }
474 0 0 if (defined $force_autolearn_names)
481 10 2 unless (defined $isspam)
500 0 2 if ($learnstatus->did_learn)
501 0 0 $isspam ? :
507 2 0 if (exists $self->{'main'}{'bayes_scanner'})
511 0 2 unless (eval {
512 0 0 $@ ne '' ? :
518 0 2 if (defined $eval_stat)
613 0 12 if (defined $names) { }
626 60 12 if exists $self->{'autolearn_points'}
636 12 0 if (($orig_scoreset & 2) == 0) { }
658 6 13 if (exists $tflags->{$test})
659 1 5 if $tflags->{$test} =~ /\bnoautolearn\b/
660 5 0 if $tflags->{$test} =~ /\buserconf\b/
664 0 0 if ($tflags->{$test} =~ /\blearn\b/)
671 0 0 if ($tflags->{$test} =~ /\bautolearn_force\b/)
679 0 13 unless $scores->{$test}
683 9 4 if ($self->{'conf'}->maybe_header_only($test)) { }
4 0 elsif ($self->{'conf'}->maybe_body_only($test)) { }
794 96 0 if (defined $mode and $mode eq 'dbg' || $mode eq 'collapsed') { }
797 54 42 unless $total_hits
807 0 84 if ($subtest_names_hit{$rule} > 1) { }
814 42 0 if ($mode eq 'dbg') { }
882 2 32 if (defined $self->{'auto_learn_force_status'})
904 4 0 unless (exists $self->{'report'})
1024 2 32 if ($self->{'is_spam'} and $self->{'conf'}{'report_safe'}) { }
1040 0 36 if ($self->{'msg'}{'line_ending'} ne "\n")
1077 0 2 if ($self->{'conf'}{'report_charset'})
1087 0 2 unless ($] < "5.008" or utf8::downgrade($report, 1))
1103 0 2 if (defined $self->{'conf'}{'rewrite_header'}{'Subject'})
1105 0 0 unless defined $subject
1106 0 0 if (defined $self->{'subjprefix'} and $self->{'subjprefix'} ne "")
1117 0 2 if (defined $self->{'conf'}{'rewrite_header'}{'To'})
1118 0 0 unless defined $to
1124 0 2 if (defined $self->{'conf'}{'rewrite_header'}{'From'})
1125 0 0 unless defined $from
1132 2 0 if defined $from
1133 2 0 if defined $to
1134 0 2 if defined $cc
1135 2 0 if defined $subject
1136 2 0 if defined $date
1137 2 0 if defined $msgid
1140 2 0 if (defined $self->{'conf'}{'report_safe_copy_headers'})
1144 0 0 if exists $already_added{lc $hdr}
1148 0 0 if (lc $hdr eq 'received') { }
1184 2 0 if (defined $ct and $ct ne '' and not $ct =~ m[text/plain]i) { }
1194 0 2 if $self->{'conf'}{'report_safe'} > 1
1249 120 0 unless $pristine_headers[$line] =~ /^X-Spam-(?!Prev-)/i
1254 32 0 if (@pristine_headers and $pristine_headers[$#pristine_headers] =~ /^\s*$/)
1260 0 32 if ($self->{'is_spam'}) { }
1266 0 0 if (not defined $subject and $self->{'is_spam'} and exists $self->{'conf'}{'rewrite_header'}{'Subject'})
1276 0 0 unless /^(From|Subject|To):/i
1278 0 0 unless defined $self->{'conf'}{'rewrite_header'}{$hdr}
1281 0 0 if ($created_subject) { }
1292 0 0 if $hdr =~ /^(?:From|To)$/
1294 0 0 if (defined $self->{'subjprefix'} and defined $self->{'conf'}{'rewrite_header'}{'Subject'})
1295 0 0 if ($self->{'subjprefix'} ne "")
1301 0 0 if (defined $ntag)
1315 0 32 if (not defined $subject and exists $self->{'conf'}{'rewrite_header'}{'Subject'})
1325 88 0 unless /^(Subject):/i
1327 0 0 unless defined $self->{'conf'}{'rewrite_header'}{$hdr}
1329 0 0 if (defined $self->{'subjprefix'} and defined $self->{'conf'}{'rewrite_header'}{'Subject'})
1330 0 0 if ($self->{'subjprefix'} ne "")
1336 0 0 if (defined $ntag)
1356 0 32 if (@pristine_headers and $pristine_headers[0] =~ /^Return-Path:/i)
1375 168 0 unless $text =~ tr/\000-\177/\200-\377/c
1378 0 0 if ($self->{'report_charset'})
1402 168 0 if ($self->{'conf'}{'fold_headers'}) { }
1403 0 168 if ($hdr_data =~ /\n/) { }
1434 0 430 if ($tag =~ /^ADDEDHEADER(?:HAM|SPAM|)\z/) { }
1439 0 430 if ref $result eq "ARRAY"
1441 430 0 defined $result ? :
1464 0 81 unless ref $code eq "CODE"
1468 81 0 !ref($tags) ? :
1482 81 0 if (not defined $data or $data eq "")
1490 81 0 if (@blocking_tags) { }
1514 0 897 if (would_log("dbg", "check"))
1516 0 0 ref $tag_val ne 'ARRAY' ? :
0 0 !defined($tag_val) ? :
1521 0 897 if (ref $self->{'tagrun_actions'}{$tag})
1524 0 0 if ($action_pending)
1526 0 0 if ($self->{'tagrun_tagscnt'}[$action_ind] <= 0) { }
0 0 elsif (not --$self->{'tagrun_tagscnt'}[$action_ind]) { }
1548 98 38 if ref $self->{'tagrun_actions'}
1552 79 0 if @pending_actions
1612 0 95 unless defined $tag
1615 4 91 if (exists $common_tags{$tag}) { }
91 0 elsif (exists $self->{'tag_data'}{$tag}) { }
1618 4 0 if ref $data eq "CODE"
1619 0 4 if ref $data eq "ARRAY"
1620 0 4 unless defined $data
1624 0 91 if ref $data eq "CODE"
1625 0 91 if ref $data eq "ARRAY"
1626 91 0 unless defined $data
1641 0 430 unless defined $tag
1643 362 68 if (exists $common_tags{$tag}) { }
68 0 elsif (exists $self->{'tag_data'}{$tag}) { }
1646 362 0 if ref $data eq "CODE"
1647 0 362 unless defined $data
1651 0 68 if ref $data eq "CODE"
1652 0 68 unless defined $data
1702 0 36 if defined $arg
1703 0 4 defined $arg_spam ? :
0 32 defined $arg_ham ? :
4 32 $self->{'is_spam'} ? :
1718 0 38 if (defined $pad and $pad =~ /^(0+| +)$/)
1720 0 0 if $count > 0
1762 0 0 if (defined &{$method;})
1813 1 95 if (defined $addr and $addr =~ /\@([^\@. \t]+\.[^@ \t]+?)[ \t]*\z/s)
1820 57 39 if (defined $addr and $addr =~ /\@([^\@. \t]+\.[^@ \t]+?)[ \t]*\z/s)
1832 95 1 unless (defined $self->{'msg'}{'metadata'}{'html'})
1992 747 2559 if (index($request, ":") >= 0)
1995 1 746 if ($1 eq 'raw') { }
742 4 elsif ($1 eq 'addr') { }
4 0 elsif ($1 eq 'name') { }
2003 15 3291 if ($request eq 'ALL') { }
0 3291 elsif ($request eq 'ALL-TRUSTED') { }
4 3287 elsif ($request eq 'ALL-INTERNAL') { }
0 3287 elsif ($request eq 'ALL-UNTRUSTED') { }
0 3287 elsif ($request eq 'ALL-EXTERNAL') { }
110 3177 elsif ($request_lc eq 'envelopefrom') { }
0 3177 elsif ($request_lc eq 'x-spam-relays-untrusted') { }
0 3177 elsif ($request_lc eq 'x-spam-relays-trusted') { }
0 3177 elsif ($request_lc eq 'x-spam-relays-external') { }
0 3177 elsif ($request_lc eq 'x-spam-relays-internal') { }
81 3096 elsif ($request_lc eq 'tocc') { }
81 3015 elsif ($request eq 'MESSAGEID') { }
2005 0 15 $getraw ? :
2059 8 73 if ($result ne "")
2061 8 0 if $result =~ /\S/
2064 73 8 if $result eq ""
2069 42 0 if defined $_
2078 633 2382 $getraw ? :
2081 357 2658 if (@results) { }
2089 153 304 if (defined $result and $getaddr || $getname)
2096 149 4 if ($getaddr) { }
4 0 elsif ($getname) { }
2110 148 1 unless ($result =~ /^".*"$/)
2133 3 1 if ($result =~ /^ \s* " (.*?) (?<!\\)" \s* < [^<>]* >/sx or $result =~ /^ \s* (.*?) \s* < [^<>]* >/sx) { }
0 1 elsif ($result =~ /^ [^(,]*? \( (.*?) \) /sx) { }
2162 825 3306 if (exists $$cache{$_[1]}) { }
2175 1189 2195 @_ > 2 ? :
747 3384 defined $found ? :
2212 0 131 if exists $self->{'tbirdurire'}
2263 0 131 if (exists $self->{'uri_list'})
2272 488 0 if ($info->{'cleaned'})
2340 492 131 if ($self->{'uri_detail_list_run'})
2379 41 60 defined $2 ? :
224 101 defined $1 ? :
2383 19 306 if exists $seen{$rawuri}
2386 0 306 if $would_log_uri_all
2389 9 297 if defined $schost and not is_fqdn_valid($schost, 1)
2394 0 297 if $rawuri =~ /^[cm]id:/i
2397 0 297 if $rawuri =~ m[^\w+:/{0,2}$]i
2406 140 157 unless ($uri =~ /^(?:https?|ftp|mailto):/i)
2407 1 139 if ($uri =~ /^ftp\./i) { }
59 80 elsif ($uri =~ /^www\d{0,2}\./i) { }
29 51 elsif (index($uri, '@') != -1) { }
2421 0 29 unless $uri =~ /\@.+?\./
2422 0 29 if index($uri, "&nbsp;") != -1
2430 0 51 if index($uri, ".") == -1
2438 36 261 if ($uri =~ /^mailto:/i)
2440 0 36 if $uri =~ /\%[0-9a-f]{2}/i
2442 2 34 unless $uri =~ /\@([^?&>]*)/
2444 3 31 unless $self->{'main'}{'registryboundaries'}->is_domain_valid($host)
2447 0 292 if $would_log_uri_all
2460 0 131 if $self->{'msg'}{'metadata'}{'html'}{'uri_truncated'}
2464 213 0 if ($self->add_uri_detail_list($uri, $info->{'types'}, "html", 0))
2466 119 94 if (exists $info->{'anchor_text'})
2487 131 0 if ($self->{'conf'}{'parse_dkim_uris'})
2528 0 505 unless defined $types
2537 0 505 if ($types->{'nocanon'}) { }
2544 0 717 if (length $cleanuri > 8192)
2551 574 143 if (defined $domain)
2559 0 505 unless %cleaned
2562 16 489 if $valid_domain and not %domains
2565 489 0 unless ($types->{'noclean'})
2566 1 488 if ($udl->{$uri}{'cleaned'})
2595 0 0 if $self->is_rule_complete($r)
2604 0 0 if (not $self->is_rule_complete($r)) { }
0 0 elsif ($elapsed > 0) { }
2610 0 0 if ($elapsed >= 1) { }
2628 0 3773 unless ($function)
2634 3490 283 if exists $TEMPORARY_EVAL_GLUE_METHODS{$function}
2638 0 283 unless exists $self->{'conf'}{'eval_plugins'}{$function}
2642 0 283 if $self->can($function) and defined &{"Mail::SpamAssassin::PerMsgStatus::" . $function;}
2658 0 283 unless (eval $evalstr . "; 1")
2659 0 0 $@ ne '' ? :
2703 84 94 if ($rule =~ /^__/)
2706 0 94 unless (defined $score)
2712 0 94 if ($score != $score)
2723 1 93 if ($score >= 10 or $score <= -10) { }
2737 34 60 $self->{'test_log_msgs'}{'TERSE'} ? :
2744 0 94 if (defined $self->{'subjprefix'} and $self->{'subjprefix'} ne "")
2824 2 184 if (defined $score) { }
2828 0 184 unless defined $score
2833 0 186 unless ($score)
2841 176 10 if (not $value or $value <= 0)
2845 0 186 if (defined $tflags_add and $tflags_add ne "")
2847 0 0 !defined($_) || $_ eq '' ? :
2852 8 178 if ($already_hit and not +($tflags_ref->{$rule} || '') =~ /\bmultiple\b/)
2862 2 176 if ($dynamic_score_provided)
2868 0 178 if (defined $rule_descr) { }
2875 122 56 if not defined $rule_descr or $rule_descr eq ""
2877 0 178 if (defined $self->{'conf'}{'rewrite_header'}{'Subject'})
2879 0 0 if (defined $rule_subjprefix)
2881 0 0 unless ($self->{'subjprefix'} =~ /\Q$rule_subjprefix\E/)
2895 0 178 if ($dups and @{$dups;})
2921 0 45 if (length $msg > 47) { }
2935 0 110 if exists $self->{'envelopefrom'}
2948 0 110 if (defined $self->{'conf'}{'envelope_sender_header'})
2952 0 0 if (defined $envf and index($envf, '@') > 0 || $envf eq '')
2959 0 0 if (defined $envf) { }
2978 102 8 unless (defined $lasthop)
2985 33 77 if (defined $lasthop)
2988 0 0 if (defined $envf and index($envf, '@') > 0 || $envf eq '')
3003 0 110 if (index($self->get("X-Sender"), "\@") != -1)
3005 0 0 if (index($rcvd, "(fetchmail") != -1)
3013 0 110 if (defined($envf = $self->get("X-Envelope-From:addr", undef)))
3016 0 0 if ($self->get('ALL') =~ /^Received:.*?^X-Envelope-From:/ism) { }
3028 0 110 if (defined($envf = $self->get("Envelope-Sender:addr", undef)))
3031 0 0 if ($self->get('ALL') =~ /^Received:.*?^Envelope-Sender:/ism) { }
3047 11 99 if (defined($envf = $self->get("Return-Path:addr", undef)))
3050 0 11 if ($self->get('ALL') =~ /^Received:.*?^Return-Path:/ism) { }
3081 0 4 if defined $end_rcvd and $end_rcvd < 0
3083 4 0 unless defined $include_start_rcvd
3084 4 0 unless defined $include_end_rcvd
3090 0 4 if ($getraw) { }
3097 0 17 if ($hdr =~ /^Received:/i)
3099 0 0 if defined $start_rcvd and not $include_start_rcvd and $start_rcvd == $cur_rcvd_index
3101 0 0 if defined $end_rcvd and not $include_end_rcvd and $end_rcvd == $cur_rcvd_index
3104 17 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) { }
3113 0 4 $result eq '' ? :
3139 0 4 if (defined $self->{'fulltext_tmpfile'})
3144 0 4 unless $tmpfh
3154 0 4 unless defined $nwrites
3156 0 4 unless close $tmpfh
3175 4 248 if (defined $self->{'fulltext_tmpfile'})
3176 0 4 unless (unlink $self->{'fulltext_tmpfile'})
3179 0 0 if ($! == 2) { }
3190 162 95 if (exists $self->{'all_from_addrs'})
3196 0 95 if (defined $resent and $resent =~ /\S/) { }
3237 0 0 if (exists $self->{'all_from_addrs_domains'})
3252 0 0 if not defined $domain or $addrs_seen{lc $domain}++
3267 81 95 if (exists $self->{'all_to_addrs'})
3273 0 95 if ($resent =~ /\S/) { }
3288 22 51 if ($line =~ / for (\S+\@\S+);/)