Branch Coverage

blib/lib/Mail/SpamAssassin/Conf/Parser.pm
Criterion Covered Total %
branch 229 366 62.5


line true false branch
186 7405 7089 if (exists $cmd->{'default'})
200 567 13927 if ($cmd->{'is_frequent'}) { }
208 162 14332 if ($cmd->{'aliases'} and scalar @{$cmd->{'aliases'};} > 0)
228 0 79 if ($lang)
236 79 0 if ($lang =~ /^(C|POSIX)$/) { }
262 45334 77722 if (index($line, '#') > -1)
264 0 45334 if ($keepmetadata and $line =~ /^\#testrules/)
270 0 45334 if ($line =~ /^\# UPDATE version (\d+)$/)
272 0 0 if defined $_ and $_ ne '(no file)'
280 63452 59604 if ($line =~ tr/\t\n\f\r //)
284 58648 64408 unless $line
287 0 0 unless $lang =~ /^$1/i
0 64408 if ($line =~ s/^lang\s+(\S+)\s+//)
293 1546 62862 unless defined $value
302 3010 61398 if ($key eq 'file') { }
0 61398 elsif ($key eq 'include') { }
756 60642 elsif ($key eq 'ifplugin') { }
189 60453 elsif ($key eq 'if') { }
0 60453 elsif ($key eq 'else') { }
945 59508 elsif ($key eq 'endif') { }
303 1505 1505 if ($value =~ /^start\s+(.+)$/)
309 1505 0 if ($value =~ /^end\s/)
312 0 1505 if (scalar @if_stack > 0)
315 0 0 if ($cond->{'type'} eq 'if') { }
332 1505 0 if (defined $curfile) { }
363 0 0 unless (@if_stack)
375 0 945 unless (defined $lastcond)
385 592 58916 if $skip_parsing
387 0 58916 if ($key eq 'require_version')
389 0 0 if $value eq '@@VERSION@@'
401 0 0 if ($ver ne $value)
415 50882 8034 unless ($cmd)
421 58910 6 if ($cmd)
422 0 58910 if ($self->{'scoresonly'})
423 0 0 if ($cmd->{'is_priv'} and not $conf->{'allow_user_rules'})
427 0 0 if ($cmd->{'is_admin'})
433 827 58083 unless ($cmd->{'code'})
434 0 827 unless ($self->setup_default_code_cb($cmd))
441 0 58910 if ($ret and $ret eq $Mail::SpamAssassin::Conf::INVALID_VALUE) { }
0 58910 elsif ($ret and $ret eq $Mail::SpamAssassin::Conf::INVALID_HEADER_FIELD_NAME) { }
0 58910 elsif ($ret and $ret eq $Mail::SpamAssassin::Conf::MISSING_REQUIRED_VALUE) { }
468 0 6 if ($conf->{'main'}->call_plugins('parse_config', {'key', $key, 'value', $value, 'line', $line, 'conf', $conf, 'user_config', $self->{'scoresonly'}}))
483 6 0 unless ($msg)
485 0 6 if ($migrated_keys{$key}) { }
517 2268 1827 if ($token =~ /^(?:\W+|[+-]?\d+(?:\.\d+)?)$/) { }
756 1071 elsif ($token eq 'plugin') { }
126 945 elsif ($token eq 'can') { }
0 945 elsif ($token eq 'has') { }
63 882 elsif ($token eq 'version') { }
0 882 elsif ($token eq 'perl_version') { }
882 0 elsif ($token =~ /^\w[\w\:]+$/) { }
550 0 945 if ($bad)
561 685 260 if (eval $eval) { }
565 0 260 if $@ ne ''
577 0 126 if ($self->{'currentfile'} =~ m[/user_prefs$])
593 0 126 if (not defined $method) { }
126 0 elsif ($method =~ /^(.*)::([^:]+)$/) { }
600 126 0 if $module->can($meth) and $fn_name eq 'has' || &{$method;}()
616 32 47 if ($conf->{'lint_rules'})
619 0 832 unless (exists $conf->{'tests'}{$k})
625 0 640 unless (exists $conf->{'tests'}{$sk})
643 2310 1259 unless (exists $conf->{'scores'}{$k})
645 0 2310 $k =~ /^T_/ ? :
647 682 1628 if ($conf->{'tflags'}{$k} || '') =~ /\bnice\b/
662 3378 191 unless ($k =~ /^(?:T_|__)/i)
663 1750 1628 unless (exists $conf->{'descriptions'}{$k})
676 126 701 if ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_STRING) { }
150 551 elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_BOOL) { }
192 359 elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_NUMERIC) { }
189 170 elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_HASH_KEY_VALUE) { }
0 170 elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_ADDRLIST) { }
126 44 elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_TEMPLATE) { }
0 44 elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_NOARGS) { }
0 44 elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_STRINGLIST) { }
44 0 elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_IPADDRLIST) { }
0 0 elsif ($type == $Mail::SpamAssassin::Conf::CONF_TYPE_DURATION) { }
716 0 0 unless (not defined $value or $value eq '')
724 0 192 unless (defined $value and not $value =~ /^$/)
727 0 192 unless ($value =~ /^ [+-]? \d+ (?: \. \d* )? \z/sx)
738 0 0 unless (defined $value and not $value =~ /^$/)
741 0 0 unless ($value =~ /^( \+? \d+ (?: \. \d* )? ) (?: \s* ([smhdw]))? \z/six)
746 0 0 if defined $2
754 0 212 unless (defined $value and not $value =~ /^$/)
760 191 21 if ($value eq 'yes' or $value eq '1') { }
21 0 elsif ($value eq 'no' or $value eq '0') { }
776 0 126 unless (defined $value and not $value =~ /^$/)
786 0 0 unless (defined $value and not $value =~ /^$/)
796 0 44 unless (defined $value and not $value =~ /^$/)
810 0 3589 unless (defined $v and $v ne '')
820 0 0 unless (defined $value and not $value =~ /^$/)
829 0 0 unless (defined $value and not $value =~ /^$/)
837 63 1008 if ($value =~ /^"(.*?)"$/)
843 0 126 unless (not defined $value or $value eq '')
857 79 0 if (not $isuserconf) { }
868 79 0 unless ($conf->{'allow_user_rules'})
880 2633 935 if (($type & 1) == 1) { }
881 2633 0 if (my($function, $args) = $text =~ /(.*?)\s*\((.*?)\)\s*$/) { }
885 0 2633 if (not $packed) { }
85 2548 elsif ($type == $Mail::SpamAssassin::Conf::TYPE_BODY_EVALS) { }
2299 249 elsif ($type == $Mail::SpamAssassin::Conf::TYPE_HEAD_EVALS) { }
1 248 elsif ($type == $Mail::SpamAssassin::Conf::TYPE_RBL_EVALS) { }
0 248 elsif ($type == $Mail::SpamAssassin::Conf::TYPE_RAWBODY_EVALS) { }
248 0 elsif ($type == $Mail::SpamAssassin::Conf::TYPE_FULL_EVALS) { }
918 233 702 if ($type == $Mail::SpamAssassin::Conf::TYPE_BODY_TESTS) { }
567 135 elsif ($type == $Mail::SpamAssassin::Conf::TYPE_HEAD_TESTS) { }
72 63 elsif ($type == $Mail::SpamAssassin::Conf::TYPE_META_TESTS) { }
63 0 elsif ($type == $Mail::SpamAssassin::Conf::TYPE_URI_TESTS) { }
0 0 elsif ($type == $Mail::SpamAssassin::Conf::TYPE_RAWBODY_TESTS) { }
0 0 elsif ($type == $Mail::SpamAssassin::Conf::TYPE_FULL_TESTS) { }
0 0 elsif ($type == $Mail::SpamAssassin::Conf::TYPE_EMPTY_TESTS) { }
946 79 0 if (not $isuserconf) { }
954 79 0 if (not $conf->{'allow_user_rules'})
969 3497 72 unless $conf->{'test_types'}{$name} == $Mail::SpamAssassin::Conf::TYPE_META_TESTS
983 0 269 if $alreadydone->{$name}
988 0 269 unless $rule
998 1902 1416 if $token =~ tr[0-9A-Z_a-z](\000-/:-@[-^`{-\377)c or substr($token, 0, 1) =~ tr/A-Z_a-z/\000-@[-^`{-\377/c
1001 1219 197 unless exists $conf_tests->{$token}
1013 0 79 unless $conf->{'meta_dependencies'}
1026 3500 72 unless defined $deps
1031 6 191 if ($deppri > $basepri)
1049 2633 936 if $type & 1 or $type eq $Mail::SpamAssassin::Conf::TYPE_EMPTY_TESTS
1057 1 935 if (defined $names_for_text{$text}) { }
1072 1 1 if (not defined $first or $priority < $first_pri)
1081 1 1 if $name eq $first
1095 2633 0 if (defined $args)
1103 1579 0 if (defined $2) { }
1112 0 2633 if ($args ne '')
1120 1018 1615 if (@args > 0)
1139 28 51 if ($conf->{'trusted_networks_configured'}) { }
1 50 elsif ($conf->{'internal_networks_configured'}) { }
1150 42 16 unless $$conf{"${net_type}_configured"}
1151 1 15 if $net_type eq $matching_against
1159 4 34 if (not $net->{'exclude'} || $nt->contains_net($net)) { }
1171 4 11 if ($replace_nets)
1186 0 3569 unless ($name =~ /^[_[:alpha:]]\w*$/)
1195 0 3569 if (length $name > 100)
1202 1792 1777 if ($conf->{'lint_rules'})
1203 0 0 if (length $name > 40 and not $name =~ /^__/ and not $name =~ /^T_/)
1210 63 3272 if ($type == $Mail::SpamAssassin::Conf::TYPE_BODY_TESTS or $type == $Mail::SpamAssassin::Conf::TYPE_FULL_TESTS or $type == $Mail::SpamAssassin::Conf::TYPE_RAWBODY_TESTS or $type == $Mail::SpamAssassin::Conf::TYPE_URI_TESTS)
1215 0 297 unless $self->is_delimited_regexp_valid($name, $text)
1217 567 3002 if ($type == $Mail::SpamAssassin::Conf::TYPE_HEAD_TESTS) { }
72 2930 elsif ($type == $Mail::SpamAssassin::Conf::TYPE_META_TESTS) { }
1221 63 504 if ($text =~ /^!?defined\([!-9;-\176]+\)$/) { }
1225 504 0 if ($pat)
1226 0 504 unless $self->is_delimited_regexp_valid($name, $pat)
1231 0 72 unless $self->is_meta_valid($name, $text)
1237 0 3569 if ($name =~ /AUTOLEARNTEST/i)
1242 72 3497 if ($type == $Mail::SpamAssassin::Conf::TYPE_META_TESTS) { }
1251 0 3569 if ($conf->{'main'}{'keep_config_parsing_metadata'})
1254 0 0 if ($self->{'file_scoped_attrs'}{'testrules'})
1272 0 3569 if ($self->{'scoresonly'})
1282 0 0 if ($conf->{'regression_tests'}{$name}) { }
1298 0 72 if ($rule =~ /\S(::|->)\S/)
1306 0 72 if (length $name == 1)
1308 0 0 unless print "$name $_\n "
1314 215 366 if ($token =~ /^[_[:alpha:]]\w+\z/s) { }
366 0 elsif ($token =~ /^(\d+|[[:punct:]]{1,2})\z/s) { }
1328 72 0 if (eval $evalstr)
1331 0 0 $@ ne '' ? :
1341 0 1242 unless ($re and $re =~ /^\s*m?(\W).*(?:\1|>|}|\)|\])[a-z]*\s*$/)
1359 64 1202 if ($re =~ s/^m\{//) { }
1 1201 elsif ($re =~ s/^m\(//) { }
1 1200 elsif ($re =~ s/^m<//) { }
129 1071 elsif ($re =~ s/^m(\W)//) { }
1057 14 elsif ($re =~ s[^/(.*)/([a-z]*)\z][$1]) { }
1378 608 658 if ($self->{'conf'}{'lint_rules'} or $self->{'conf'}{'ignore_always_matching_regexps'})
1383 0 608 if (defined $msg)
1384 0 0 if ($self->{'conf'}{'lint_rules'}) { }
1394 907 359 if ($mods)
1403 1262 4 if (eval { do { '' =~ /$re/; 1 } })
1405 4 0 $@ ne '' ? :
1415 2 618 if ($re =~ /(?<!\\)\|\|/) { }
1 617 elsif ($re =~ /^\|/) { }
1 616 elsif ($re =~ /\|(?<!\\\|)$/) { }
1452 0 0 if ($conf->{$listname}{$addr}) { }
1494 0 0 if ($conf_lname->{$addr})
1499 0 0 if (not @replacement) { }
0 0 elsif (@replacement != @$domains_listref) { }
1516 0 0 unless ('File::Spec'->file_name_is_absolute($path))
1529 8 6 unless (defined $iserror)
1531 4 10 if ($self->{'conf'}{'main'}{'lint_callback'}) { }
0 10 elsif ($self->{'conf'}{'lint_rules'}) { }
1545 14 0 if ($iserror)