Branch Coverage

blib/lib/Mail/SpamAssassin/PerMsgStatus.pm
Criterion Covered Total %
branch 284 558 50.9


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 154 0 if $self->{'master_deadline'}
290 49 0 if (defined $opts and $opts->{'disable_auto_learning'})
295 0 154 if ($self->{'main'}{'save_pattern_hits'})
302 0 154 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 { 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 } })
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 if (defined $self->{'subjprefix'} and $self->{'subjprefix'} ne '')
1111 0 0 unless defined $subject
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 607 2887 if (index($request, ':') >= 0)
1995 1 606 if ($1 eq 'raw') { }
602 4 elsif ($1 eq 'addr') { }
4 0 elsif ($1 eq 'name') { }
2003 15 3479 if ($request eq 'ALL') { }
0 3479 elsif ($request eq 'ALL-TRUSTED') { }
4 3475 elsif ($request eq 'ALL-INTERNAL') { }
0 3475 elsif ($request eq 'ALL-UNTRUSTED') { }
0 3475 elsif ($request eq 'ALL-EXTERNAL') { }
110 3365 elsif ($request_lc eq 'envelopefrom') { }
0 3365 elsif ($request_lc eq 'x-spam-relays-untrusted') { }
0 3365 elsif ($request_lc eq 'x-spam-relays-trusted') { }
0 3365 elsif ($request_lc eq 'x-spam-relays-external') { }
0 3365 elsif ($request_lc eq 'x-spam-relays-internal') { }
81 3284 elsif ($request_lc eq 'tocc') { }
81 3203 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 493 2710 $getraw ? :
2081 357 2846 if (@results) { }
2089 142 315 if (defined $result and $getaddr || $getname)
2096 138 4 if ($getaddr) { }
4 0 elsif ($getname) { }
2110 137 1 unless ($result =~ /^".*"$/)
2133 3 1 if ($result =~ /^ \s* " (.*?) (?<!\\)" \s* < [^<>]* >/sx or $result =~ /^ \s* (.*?) \s* < [^<>]* >/sx) { }
0 1 elsif ($result =~ /^ [^(,]*? \( (.*?) \) /sx) { }
2162 554 3494 if (exists $$cache{$_[1]}) { }
2175 795 2514 @_ > 2 ? :
739 3309 defined $found ? :
2212 0 130 if exists $self->{'tbirdurire'}
2263 0 130 if (exists $self->{'uri_list'})
2272 401 0 if ($info->{'cleaned'})
2340 405 130 if ($self->{'uri_detail_list_run'})
2379 41 60 defined $2 ? :
223 101 defined $1 ? :
2383 19 305 if exists $seen{$rawuri}
2386 0 305 if $would_log_uri_all
2389 9 296 if defined $schost and not is_fqdn_valid($schost, 1)
2394 0 296 if $rawuri =~ /^[cm]id:/i
2397 0 296 if $rawuri =~ m[^\w+:/{0,2}$]i
2406 140 156 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 260 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 291 if $would_log_uri_all
2460 0 130 if $self->{'msg'}{'metadata'}{'html'}{'uri_truncated'}
2464 127 0 if ($self->add_uri_detail_list($uri, $info->{'types'}, 'html', 0))
2466 118 9 if (exists $info->{'anchor_text'})
2487 130 0 if ($self->{'conf'}{'parse_dkim_uris'})
2528 0 418 unless defined $types
2537 0 418 if ($types->{'nocanon'}) { }
2544 0 558 if (length $cleanuri > 8192)
2551 445 113 if (defined $domain)
2559 0 418 unless %cleaned
2562 16 402 if $valid_domain and not %domains
2565 402 0 unless ($types->{'noclean'})
2566 1 401 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) { }
2946 0 110 if (defined $self->{'conf'}{'envelope_sender_header'})
2950 0 0 if defined $envf and $envf =~ /\@/ || $envf eq ''
2952 0 0 if (defined $envf) { }
2970 102 8 unless (defined $lasthop)
2976 33 77 if (defined $lasthop)
2980 0 33 if ($envf and $envf =~ /\@/)
2993 0 110 if ($self->get('X-Sender') =~ /\@/)
2995 0 0 if ($rcvd =~ /\(fetchmail/)
3002 0 110 if ($envf = $self->get('X-Envelope-From'))
3005 0 0 if ($self->get('ALL') =~ /^Received:.*?^X-Envelope-From:/ism) { }
3014 0 110 if ($envf = $self->get('Envelope-Sender'))
3017 0 0 if ($self->get('ALL') =~ /^Received:.*?^Envelope-Sender:/ism) { }
3031 11 99 if ($envf = $self->get('Return-Path'))
3034 0 11 if ($self->get('ALL') =~ /^Received:.*?^Return-Path:/ism) { }
3068 0 4 if defined $end_rcvd and $end_rcvd < 0
3070 4 0 unless defined $include_start_rcvd
3071 4 0 unless defined $include_end_rcvd
3077 0 4 if ($getraw) { }
3084 0 17 if ($hdr =~ /^Received:/i)
3086 0 0 if defined $start_rcvd and not $include_start_rcvd and $start_rcvd == $cur_rcvd_index
3088 0 0 if defined $end_rcvd and not $include_end_rcvd and $end_rcvd == $cur_rcvd_index
3091 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) { }
3100 0 4 $result eq '' ? :
3126 0 4 if (defined $self->{'fulltext_tmpfile'})
3131 0 4 unless $tmpfh
3141 0 4 unless defined $nwrites
3143 0 4 unless close $tmpfh
3162 4 247 if (defined $self->{'fulltext_tmpfile'})
3163 0 4 unless (unlink $self->{'fulltext_tmpfile'})
3166 0 0 if ($! == 2) { }
3177 162 95 if (exists $self->{'all_from_addrs'})
3183 0 95 if (defined $resent and $resent =~ /\S/) { }
3224 0 0 if (exists $self->{'all_from_addrs_domains'})
3239 0 0 if not defined $domain or $addrs_seen{lc $domain}++
3254 81 95 if (exists $self->{'all_to_addrs'})
3260 0 95 if ($resent =~ /\S/) { }
3275 22 51 if ($line =~ / for (\S+\@\S+);/)