Branch Coverage

blib/lib/Mail/SpamAssassin/Plugin/Bayes.pm
Criterion Covered Total %
branch 158 342 46.2


line true false branch
53 0 21 unless (eval { do { require Digest::SHA; 'Digest::SHA'->import('sha1', 'sha1_hex'); 1 } })
245 39 1 if ($self->{'store'})
267 0 0 if ($self->{'store'} and $self->{'store'}->UNIVERSAL::can('prefork_init'))
279 0 0 if ($self->{'store'} and $self->{'store'}->UNIVERSAL::can('spamd_child_init'))
290 0 0 unless $self->{'conf'}{'use_learner'}
291 0 0 unless $self->{'conf'}{'use_bayes'} and $self->{'conf'}{'use_bayes_rules'}
293 0 0 unless (exists $pms->{'bayes_score'})
298 0 0 if (defined $pms->{'bayes_score'} and $min == 0 || $pms->{'bayes_score'} > $min and $max eq 'undef' || $pms->{'bayes_score'} <= $max)
302 0 0 if ($self->{'conf'}{'detailed_bayes_score'}) { }
326 0 6 if ($self->{'store'}->db_readable)
327 0 0 unless $quiet
348 0 0 unless $self->{'use_ignores'}
357 0 0 if $ignore
371 0 10 unless ($self->{'conf'}{'use_bayes'})
381 2 8 if ($self->{'main'}{'learn_to_journal'}) { }
390 8 2 if ($ok)
393 8 0 unless ($self->{'main'}{'learn_caller_will_untie'})
398 0 10 unless (eval { do { local $SIG{'__DIE__'}; my $timer = $self->{'main'}->time_method('b_learn'); my $ok; if ($self->{'main'}{'learn_to_journal'}) { $ok = $self->{'store'}->tie_db_readonly || $self->{'store'}->tie_db_writable; } else { $ok = $self->{'store'}->tie_db_writable; } ; if ($ok) { $ret = $self->_learn_trapped($isspam, $msg, $msgdata, $id); unless ($self->{'main'}{'learn_caller_will_untie'}) { $self->{'store'}->untie_db; } ; } ; 1 } })
399 0 0 $@ ne '' ? :
412 8 0 unless (defined $msgid)
419 4 8 if (defined $seen)
420 2 2 if ($seen eq 's' and $isspam or $seen eq 'h' and not $isspam) { }
0 2 elsif (not $seen =~ /^[hs]$/) { }
429 0 2 if ($self->{'main'}{'learn_no_relearn'})
446 0 2 if ($fatal)
467 0 6 if $msgatime - time > 86400
472 4 2 if ($isspam) { }
481 4 2 $isspam ? :
503 0 4 unless ($self->{'conf'}{'use_bayes'})
515 0 4 if ($self->{'main'}{'learn_to_journal'}) { }
524 4 0 if ($ok)
527 2 2 unless ($self->{'main'}{'learn_caller_will_untie'})
532 0 4 unless (eval { do { local $SIG{'__DIE__'}; my $timer = $self->{'main'}->time_method('b_learn'); my $ok; if ($self->{'main'}{'learn_to_journal'}) { $ok = $self->{'store'}->tie_db_readonly || $self->{'store'}->tie_db_writable; } else { $ok = $self->{'store'}->tie_db_writable; } ; if ($ok) { $ret = $self->_forget_trapped($msg, $msgdata, $id); unless ($self->{'main'}{'learn_caller_will_untie'}) { $self->{'store'}->untie_db; } ; } ; 1 } })
533 0 0 $@ ne '' ? :
547 4 0 unless (defined $msgid)
554 4 0 if (defined $seen) { }
555 2 2 if ($seen eq 's') { }
2 0 elsif ($seen eq 'h') { }
574 0 4 if (not defined $isspam) { }
2 2 elsif ($isspam) { }
587 2 2 if ($isspam) { }
609 0 2 unless ($self->{'conf'}{'use_bayes'})
620 0 0 unless ($self->{'conf'}{'use_bayes'})
635 0 145 unless $self->{'conf'}{'use_bayes'}
636 139 6 unless $self->{'store'}->tie_db_readonly
652 0 6 if ($ns < $self->{'conf'}{'bayes_min_spam_num'})
654 0 0 unless ($self->{'main'}{'learn_caller_will_untie'})
659 0 6 if ($nn < $self->{'conf'}{'bayes_min_ham_num'})
661 0 0 unless ($self->{'main'}{'learn_caller_will_untie'})
676 0 4 unless $self->{'conf'}{'use_learner'}
683 0 4 if $self->{'main'}{'bayes_scanner'}->ignore_message($permsgstatus)
685 0 4 unless $self->learner_is_scan_available
714 602 502 unless defined $prob
728 0 4 unless (@pw_keys)
742 0 4 if $msgatime > $now
756 2 2 if (@pw_keys > 150)
760 132 282 if $tok_strength{$tok} < $Mail::SpamAssassin::Bayes::Combine::MIN_PROB_STRENGTH
775 250 32 $pw_prob < 0.5 ? :
783 0 282 if ($log_each_token)
788 0 4 if (not @sorted or !1)
799 0 4 unless defined $score
828 0 4 unless (defined $score)
833 4 0 unless (defined $timer_finish)
838 0 4 if ($self->{'main'}{'opportunistic_expire_check_only'}) { }
855 4 0 unless ($caller_untie)
860 4 0 $tinfo_hammy ? :
862 4 0 $tinfo_spammy ? :
880 0 0 if (defined $pms->{'tag_data'}{'BAYESTC'}) { }
911 0 0 unless $self->{'store'}->tie_db_readonly
919 0 0 if ($magic)
920 0 0 unless printf $template, 0, 0, $bv, 0, 'non-token data: bayes db version'
922 0 0 unless printf $template, 0, 0, $ns, 0, 'non-token data: nspam'
924 0 0 unless printf $template, 0, 0, $nh, 0, 'non-token data: nham'
926 0 0 unless printf $template, 0, 0, $nt, 0, 'non-token data: ntokens'
928 0 0 unless printf $template, 0, 0, $oa, 0, 'non-token data: oldest atime'
930 0 0 if ($bv >= 2)
931 0 0 unless printf $template, 0, 0, $na, 0, 'non-token data: newest atime'
934 0 0 if ($bv < 2)
935 0 0 unless printf $template, 0, 0, $sb, 0, 'non-token data: current scan-count'
938 0 0 if ($bv >= 2)
939 0 0 unless printf $template, 0, 0, $js, 0, 'non-token data: last journal sync atime'
942 0 0 unless printf $template, 0, 0, $le, 0, 'non-token data: last expiry atime'
944 0 0 if ($bv >= 2)
945 0 0 unless printf $template, 0, 0, $ad, 0, 'non-token data: last expire atime delta'
948 0 0 unless printf $template, 0, 0, $er, 0, 'non-token data: last expire reduction count'
953 0 0 if ($toks)
958 0 0 unless ($self->{'main'}{'learn_caller_will_untie'})
973 14 0 if (defined $msgid and $msgid ne '' and not $msgid =~ /^\s*<\s*(?:\@sa_generated)?>.*$/)
986 0 14 if not defined $date or $date eq ''
996 14 0 if (length $body > 64)
997 14 0 length $body > 2048 ? :
1007 14 0 wantarray ? :
1013 0 20 unless (ref $msg)
1025 0 20 unless (defined $msgdata)
1040 24 0 if $t_src->{'visible'}
1042 24 0 if $t_src->{'invisible'}
1044 0 24 if $t_src->{'mimepart'}
1046 24 0 if $t_src->{'uri'}
1060 16 0 if ($msgdata->{'bayes_token_body'})
1067 16 0 if ($msgdata->{'bayes_token_uris'})
1074 16 0 if ($msgdata->{'bayes_token_inviz'})
1078 16 0 if (defined $tokprefix)
1087 0 16 if ($msgdata->{'bayes_mimepart_digests'})
1105 16 0 if ($t_src->{'header'})
1120 6714 0 if $token ne ''
1146 2368 2476 defined $1 ? :
1156 332 200 if ($region == 1 or $region == 2)
1178 0 8592 if defined $magic_re and $token =~ /$magic_re/
1187 3362 5230 if $len < 3 or $token =~ /^(?:a(?:ble|l(?:ready|l)|n[dy]|re)|b(?:ecause|oth)|c(?:an|ome)|e(?:ach|mail|ven)|f(?:ew|irst|or|rom)|give|h(?:a(?:ve|s)|ttp)|i(?:n(?:formation|to)|t\'s)|just|know|l(?:ike|o(?:ng|ok))|m(?:a(?:de|il(?:(?:ing|to))?|ke|ny)|o(?:re|st)|uch)|n(?:eed|o[tw]|umber)|o(?:ff|n(?:ly|e)|ut|wn)|p(?:eople|lace)|right|s(?:ame|ee|uch)|t(?:h(?:at|is|rough|e)|ime)|using|w(?:eb|h(?:ere|y)|ith(?:out)?|or(?:ld|k))|y(?:ears?|ou(?:(?:\'re|r))?))$/i
1191 3534 1696 if ($region == 1 or $region == 2)
1192 38 3496 if ($token =~ /\S\@\S/i) { }
110 3386 elsif ($token =~ /\S\.[a-z]/i) { }
1207 250 4980 if ($len > 15 and not $token =~ /\*/)
1209 0 250 if ($token =~ /[\x80-\xBF]{2}/)
1214 0 0 if (@t)
1230 78 18 if ($region == 0 and 1 or $region == 1 and 1 or $region == 2 and 0)
1251 3534 1696 if ($region == 1 or $region == 2)
1253 358 3176 if ($token =~ /[^\w:\*]/)
1259 712 2822 if ($token =~ /[A-Z]/)
1263 76 636 if ($token =~ /[^\w:\*]/)
1290 52 150 if (/^Received:/i)
1295 48 102 if /^$IGNORED_HDRS:/i
1303 14 2 if ($#rcvdlines >= 0)
1304 14 2 if ($#rcvdlines >= 1)
1307 0 194 unless /\S/
1312 0 194 if exists $user_ignore{lc $hdr}
1319 16 178 if ($hdr =~ /^(?:|X-|Resent-)Message-Id$/i) { }
60 118 elsif ($hdr =~ /^(?:|X-|Resent-) (?:Return-Path|From|To|Cc|Reply-To|Errors-To|Mail-Followup-To|Sender)$/xi) { }
28 90 elsif ($hdr eq 'Received') { }
4 86 elsif ($hdr eq 'Content-Type') { }
2 84 elsif ($hdr eq 'MIME-Version') { }
0 84 elsif ($hdr =~ /^$MARK_PRESENCE_ONLY_HDRS$/i) { }
1341 16 178 if ($hdr =~ /^(?:In-Reply-To|References|Message-ID)$/i)
1346 32 162 if ($hdr =~ /^(?:From|To|Cc)$/i)
1351 0 194 if ($hdr =~ /^(?:X-Mailer|User-Agent)$/i)
1357 126 68 if (defined $HEADER_NAME_COMPRESSION{$hdr})
1361 26 168 if (exists $parsed{$hdr}) { }
1366 0 194 if (would_log('dbg', 'bayes') > 1)
1378 0 4 if ($val =~ s/boundary=[\"\'](.*?)[\"\']/ /gi)
1380 0 0 unless defined $boundary
1443 0 30 if ($2 eq '10' or $2 eq '192' and $3 eq '168') { }
1474 0 86 unless $addr =~ /(.+)\@(.+)$/
1489 0 4 unless $ns and $nn
1495 0 4 unless ($self->{'use_hapaxes'})
1505 502 602 if ($s + $n >= $threshold)
1547 0 0 unless (defined $s and defined $n)
1550 0 0 unless $s or $n
1572 0 0 if $ns == 0 and $nn == 0
1575 0 0 if $ns + $nn < 2
0 0 unless ($self->{'use_hapaxes'})
1577 0 0 if $Ns == 0 or $Nn == 0
1578 0 0 if abs $prob - 0.5 < $Mail::SpamAssassin::Bayes::Combine::MIN_PROB_STRENGTH
1581 0 0 $prob > 0.5 ? :
1593 0 0 $discrim < 0 ? :
1597 0 0 $dd_exact < 1 ? :
1606 0 10 unless ($self->{'store'}->db_readable)
1613 0 10 if (defined $running_expire and $running_expire + $OPPORTUNISTIC_LOCK_VALID > time)
1619 0 10 if (not $journal_only and $self->{'store'}->expiry_due) { }
0 10 elsif ($self->{'store'}->sync_due) { }
1633 0 0 if ($self->{'store'}->db_writable)
1648 56 6 if (not $module) { }
6 0 elsif ($module =~ /^([_A-Za-z0-9:]+)$/) { }
1662 0 62 unless (eval "\n require " . $module . ";\n \$store = " . $module . "->new(\$self);\n 1;\n ")
1663 0 0 $@ ne '' ? :
1677 0 0 unless defined $info
1691 0 0 !$fmt_arg ? :
1693 0 0 unless defined $raw_fmt
1697 0 0 $limit < @$info ? :
1698 0 0 unless $amt
1702 0 0 $_[0] > 9 ? :
1711 0 0 $prob < 0.5 ? :