Branch Coverage

blib/lib/Mail/SpamAssassin/Plugin/Bayes.pm
Criterion Covered Total %
branch 157 340 46.1


line true false branch
53 0 22 unless (eval { do { require Digest::SHA; 'Digest::SHA'->import('sha1', 'sha1_hex'); 1 } })
244 39 1 if ($self->{'store'})
266 0 0 if ($self->{'store'} and $self->{'store'}->UNIVERSAL::can('prefork_init'))
278 0 0 if ($self->{'store'} and $self->{'store'}->UNIVERSAL::can('spamd_child_init'))
289 0 0 unless $self->{'conf'}{'use_learner'}
290 0 0 unless $self->{'conf'}{'use_bayes'} and $self->{'conf'}{'use_bayes_rules'}
292 0 0 unless (exists $pms->{'bayes_score'})
297 0 0 if (defined $pms->{'bayes_score'} and $min == 0 || $pms->{'bayes_score'} > $min and $max eq 'undef' || $pms->{'bayes_score'} <= $max)
301 0 0 if ($self->{'conf'}{'detailed_bayes_score'}) { }
325 0 6 if ($self->{'store'}->db_readable)
326 0 0 unless $quiet
347 0 0 unless $self->{'use_ignores'}
356 0 0 if $ignore
370 0 10 unless ($self->{'conf'}{'use_bayes'})
380 2 8 if ($self->{'main'}{'learn_to_journal'}) { }
389 8 2 if ($ok)
392 8 0 unless ($self->{'main'}{'learn_caller_will_untie'})
397 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 } })
398 0 0 $@ ne '' ? :
411 8 0 unless (defined $msgid)
418 4 8 if (defined $seen)
419 2 2 if ($seen eq 's' and $isspam or $seen eq 'h' and not $isspam) { }
0 2 elsif (not $seen =~ /^[hs]$/) { }
428 0 2 if ($self->{'main'}{'learn_no_relearn'})
445 0 2 if ($fatal)
466 0 6 if $msgatime - time > 86400
471 4 2 if ($isspam) { }
480 4 2 $isspam ? :
502 0 4 unless ($self->{'conf'}{'use_bayes'})
514 0 4 if ($self->{'main'}{'learn_to_journal'}) { }
523 4 0 if ($ok)
526 2 2 unless ($self->{'main'}{'learn_caller_will_untie'})
531 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 } })
532 0 0 $@ ne '' ? :
546 4 0 unless (defined $msgid)
553 4 0 if (defined $seen) { }
554 2 2 if ($seen eq 's') { }
2 0 elsif ($seen eq 'h') { }
573 0 4 if (not defined $isspam) { }
2 2 elsif ($isspam) { }
586 2 2 if ($isspam) { }
608 0 2 unless ($self->{'conf'}{'use_bayes'})
619 0 0 unless ($self->{'conf'}{'use_bayes'})
634 0 146 unless $self->{'conf'}{'use_bayes'}
635 140 6 unless $self->{'store'}->tie_db_readonly
651 0 6 if ($ns < $self->{'conf'}{'bayes_min_spam_num'})
653 0 0 unless ($self->{'main'}{'learn_caller_will_untie'})
658 0 6 if ($nn < $self->{'conf'}{'bayes_min_ham_num'})
660 0 0 unless ($self->{'main'}{'learn_caller_will_untie'})
675 0 4 unless $self->{'conf'}{'use_learner'}
682 0 4 if $self->{'main'}{'bayes_scanner'}->ignore_message($permsgstatus)
684 0 4 unless $self->learner_is_scan_available
713 602 502 unless defined $prob
727 0 4 unless (@pw_keys)
741 0 4 if $msgatime > $now
755 2 2 if (@pw_keys > 150)
759 142 272 if $tok_strength{$tok} < $Mail::SpamAssassin::Bayes::Combine::MIN_PROB_STRENGTH
774 244 28 $pw_prob < 0.5 ? :
782 0 272 if ($log_each_token)
787 0 4 if (not @sorted or !1)
798 0 4 unless defined $score
827 0 4 unless (defined $score)
832 4 0 unless (defined $timer_finish)
837 0 4 if ($self->{'main'}{'opportunistic_expire_check_only'}) { }
854 4 0 unless ($caller_untie)
859 4 0 $tinfo_hammy ? :
861 4 0 $tinfo_spammy ? :
879 0 0 if (defined $pms->{'tag_data'}{'BAYESTC'}) { }
910 0 0 unless $self->{'store'}->tie_db_readonly
918 0 0 if ($magic)
919 0 0 unless printf $template, 0, 0, $bv, 0, 'non-token data: bayes db version'
921 0 0 unless printf $template, 0, 0, $ns, 0, 'non-token data: nspam'
923 0 0 unless printf $template, 0, 0, $nh, 0, 'non-token data: nham'
925 0 0 unless printf $template, 0, 0, $nt, 0, 'non-token data: ntokens'
927 0 0 unless printf $template, 0, 0, $oa, 0, 'non-token data: oldest atime'
929 0 0 if ($bv >= 2)
930 0 0 unless printf $template, 0, 0, $na, 0, 'non-token data: newest atime'
933 0 0 if ($bv < 2)
934 0 0 unless printf $template, 0, 0, $sb, 0, 'non-token data: current scan-count'
937 0 0 if ($bv >= 2)
938 0 0 unless printf $template, 0, 0, $js, 0, 'non-token data: last journal sync atime'
941 0 0 unless printf $template, 0, 0, $le, 0, 'non-token data: last expiry atime'
943 0 0 if ($bv >= 2)
944 0 0 unless printf $template, 0, 0, $ad, 0, 'non-token data: last expire atime delta'
947 0 0 unless printf $template, 0, 0, $er, 0, 'non-token data: last expire reduction count'
952 0 0 if ($toks)
957 0 0 unless ($self->{'main'}{'learn_caller_will_untie'})
972 14 0 if (defined $msgid and $msgid ne '' and not $msgid =~ /^\s*<\s*(?:\@sa_generated)?>.*$/)
985 0 14 if not defined $date or $date eq ''
995 14 0 if (length $body > 64)
996 14 0 length $body > 2048 ? :
1006 14 0 wantarray ? :
1012 0 20 unless (ref $msg)
1024 0 20 unless (defined $msgdata)
1039 24 0 if $t_src->{'visible'}
1041 24 0 if $t_src->{'invisible'}
1043 0 24 if $t_src->{'mimepart'}
1045 24 0 if $t_src->{'uri'}
1059 16 0 if ($msgdata->{'bayes_token_body'})
1066 16 0 if ($msgdata->{'bayes_token_uris'})
1073 16 0 if ($msgdata->{'bayes_token_inviz'})
1077 16 0 if (defined $tokprefix)
1086 0 16 if ($msgdata->{'bayes_mimepart_digests'})
1104 16 0 if ($t_src->{'header'})
1119 6746 0 if $token ne ''
1145 2368 2476 defined $1 ? :
1155 338 200 if ($region == 1 or $region == 2)
1177 0 8598 if defined $magic_re and $token =~ /$magic_re/
1186 3362 5236 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
1190 3540 1696 if ($region == 1 or $region == 2)
1191 44 3496 if ($token =~ /\S\@\S/i) { }
110 3386 elsif ($token =~ /\S\.[a-z]/i) { }
1206 256 4980 if ($len > 15 and not $token =~ /\*/)
1208 0 256 if ($token =~ /[\x80-\xBF]{2}/)
1213 0 0 if (@t)
1229 78 24 if ($region == 0 and 1 or $region == 1 and 1 or $region == 2 and 0)
1250 3540 1696 if ($region == 1 or $region == 2)
1252 364 3176 if ($token =~ /[^\w:\*]/)
1258 712 2828 if ($token =~ /[A-Z]/)
1262 76 636 if ($token =~ /[^\w:\*]/)
1289 52 150 if (/^Received:/i)
1294 48 102 if /^$IGNORED_HDRS:/i
1302 14 2 if ($#rcvdlines >= 0)
1303 14 2 if ($#rcvdlines >= 1)
1306 0 194 unless /\S/
1311 0 194 if exists $user_ignore{lc $hdr}
1318 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) { }
1340 16 178 if ($hdr =~ /^(?:In-Reply-To|References|Message-ID)$/i)
1345 32 162 if ($hdr =~ /^(?:From|To|Cc)$/i)
1350 0 194 if ($hdr =~ /^(?:X-Mailer|User-Agent)$/i)
1356 126 68 if (defined $HEADER_NAME_COMPRESSION{$hdr})
1360 26 168 if (exists $parsed{$hdr}) { }
1365 0 194 if (would_log('dbg', 'bayes') > 1)
1377 0 4 if ($val =~ s/boundary=[\"\'](.*?)[\"\']/ /gi)
1379 0 0 unless defined $boundary
1442 0 30 if ($2 eq '10' or $2 eq '192' and $3 eq '168') { }
1473 0 92 unless $addr =~ /(.+)\@(.+)$/
1488 0 4 unless $ns and $nn
1494 0 4 unless ($self->{'use_hapaxes'})
1504 502 602 if ($s + $n >= $threshold)
1546 0 0 unless (defined $s and defined $n)
1549 0 0 unless $s or $n
1571 0 0 if $ns == 0 and $nn == 0
1574 0 0 if $ns + $nn < 2
0 0 unless ($self->{'use_hapaxes'})
1576 0 0 if $Ns == 0 or $Nn == 0
1577 0 0 if abs $prob - 0.5 < $Mail::SpamAssassin::Bayes::Combine::MIN_PROB_STRENGTH
1580 0 0 $prob > 0.5 ? :
1592 0 0 $discrim < 0 ? :
1596 0 0 $dd_exact < 1 ? :
1605 0 10 unless ($self->{'store'}->db_readable)
1612 0 10 if (defined $running_expire and $running_expire + $OPPORTUNISTIC_LOCK_VALID > time)
1618 0 10 if (not $journal_only and $self->{'store'}->expiry_due) { }
0 10 elsif ($self->{'store'}->sync_due) { }
1632 0 0 if ($self->{'store'}->db_writable)
1647 57 6 unless $module
1655 0 63 unless (eval "\n require " . $module . ";\n \$store = " . $module . "->new(\$self);\n 1;\n ")
1656 0 0 $@ ne '' ? :
1670 0 0 unless defined $info
1684 0 0 !$fmt_arg ? :
1686 0 0 unless defined $raw_fmt
1690 0 0 $limit < @$info ? :
1691 0 0 unless $amt
1695 0 0 $_[0] > 9 ? :
1704 0 0 $prob < 0.5 ? :