Branch Coverage

blib/lib/Config/Param.pm
Criterion Covered Total %
branch 489 778 62.8


line true false branch
67 65 2 ref $_[0] eq 'HASH' ? :
71 66 1 if (ref $_[0] eq 'ARRAY') { }
74 64 2 if (ref $_[0] eq "ARRAY")
94 64 3 if $give_error
187 0 657 defined $def->{'type'} && !defined($def->{'value'}) ? :
203 0 234 unless defined $h{'short'}
204 178 56 unless defined $h{'flags'}
212 0 79 if defined $config and defined $config->{'version'}
221 251 8 defined $def->{'short'} ? :
224 0 259 if defined $def->{'section'}
225 1 0 defined $def->{'long'} ? :
1 258 unless valid_def($def)
228 1 0 defined $def->{'short'} ? :
1 257 if $$name_there{$def->{'long'}} or $name_there->{$short}
230 257 0 if defined $def->{'long'}
231 209 48 if $short ne ""
245 69 1 if (@{$indef;})
247 33 36 if (ref $indef->[0] ne '') { }
253 0 86 if $t eq ""
255 0 86 if $t ne "ARRAY" and $t ne "HASH"
258 61 25 $t eq 'ARRAY' ? :
261 0 86 if $problem
266 0 36 if @{$indef;} % 4
274 2 171 if $problem
286 2 141 unless defined $_[0]
290 16 157 if /^\s/
306 1 69 unless defined $self->{'config'}
308 1 69 unless defined $pars
312 40 30 unless defined $self->{'config'}{'program'}
313 40 30 unless exists $self->{'config'}{'shortdefaults'}
327 0 15 if ($self->{'config'}{'lazy'} and $self->{'config'}{'posixhelp'})
333 0 70 $self->{'config'}{'posixhelp'} ? :
335 0 70 $self->{'config'}{'posixhelp'} ? :
361 69 1 $self->{'config'}{'shortdefaults'} ? :
369 1 0 unless (defined $_[2])
376 69 1 $self->{'config'}{'shortdefaults'} ? :
380 0 70 if defined $self->{'config'}{'version'}
384 0 70 if exists $self->{'config'}{'ignorehelp'}
386 0 70 if exists $self->{'config'}{'eval'}
389 2 68 if ($problem) { }
399 0 252 unless $self->define($def)
420 342 56 unless defined $val
421 0 342 $val eq '' ? :
56 342 $flags & $arg ? :
435 140 257 ref $pd->{'help'} ? :
397 71 defined $pd->{'help'} ? :
437 70 398 if (exists $pd->{'section'})
442 0 70 defined $pd->{'flags'} ? :
443 70 0 defined $pd->{'level'} ? :
447 0 70 if @{$self->{'section'};}
455 0 398 unless (@{$self->{'section'};})
464 1 397 unless defined $pd->{'help'}
465 8 390 unless defined $pd->{'short'}
467 0 398 unless (valid_def($pd, $type))
474 387 11 defined $pd->{'flags'} ? :
476 0 398 if defined $pd->{'addflags'}
479 160 238 defined $pd->{'regex'} ? :
482 82 316 defined $pd->{'call'} ? :
483 0 398 if ($flags & $switch and $flags & $arg)
488 0 398 if (defined $self->{'param'}{$name} or defined $self->{'long'}{$pd->{'short'}}) { }
495 212 186 if (ref $pd->{'value'}) { }
507 346 52 if $pd->{'short'} ne ""
513 0 398 defined $pd->{'level'} ? :
516 70 328 if $lev < $section->{'minlevel'}
519 0 398 if $self->{'flags'}{$name} & $switch
524 144 254 if length $name > $self->{'length'}
527 144 254 if $arglen > $self->{'arglength'}
528 160 238 if defined $regex
530 82 316 if defined $call
545 0 68 if (defined $self->{'config'}{'file'})
549 0 0 ref $self->{'config'}{'file'} eq 'ARRAY' ? :
554 42 26 unless ($self->{'config'}{'nofile'} or @{$self->{'param'}{'config'};})
560 11 31 if defined $pconf
561 0 42 if defined $hconf
565 42 0 unless ($self->{'config'}{'multi'})
567 11 31 if @l
581 69 0 if (defined(my $name = $self->{'long'}{$s})) { }
587 0 0 if ($self->{'config'}{'fuzzy'}) { }
595 0 0 unless ($self->{'config'}{'ignore_unknown'} and $self->{'config'}{'ignore_unknown'} > 1)
616 205 1 if my $arrhash = defined $self->{'type'}{$name}
621 158 48 if (defined $_[0] and $arrhash) { }
16 33 elsif (not defined $_[0] and $flags & $arg) { }
624 16 142 if ($_[0] eq "/" and $_[1] =~ m[(./)(=?)(.*)])
627 4 12 $3 eq '' && $2 eq '' ? :
628 4 12 if $2 eq "" and defined $_[1]
631 8 150 if ($_[0] =~ m[^/./$] and $flags & $arg)
633 0 8 unless (@{$_[2];})
636 0 0 $self->{'short'}{$name} ne '' ? :
644 0 16 unless ($lastoption and @{$_[2];})
647 0 0 $self->{'short'}{$name} ne '' ? :
655 31 175 unless defined $_[0]
660 6 200 if (defined $self->{'call'}{$name})
664 1 5 if ($ret or (not defined $nname or $nname ne $name))
666 0 1 if $ret
675 30 175 unless (defined $_[0])
677 0 30 if ($flags & $count) { }
679 0 0 $sign =~ /^-/ ? :
684 30 0 $sign =~ /^-/ ? :
687 204 1 if ($arrhash)
690 61 143 if $self->{'flags'}{$name} & $append
701 149 57 unless defined $self->{'ops'}{$name}
703 1 205 unless defined $op
705 199 6 $op =~ /=$/ ? :
718 0 66 if $self->{'config'}{'gimme'} and not @{$args;}
725 15 51 if ($self->{'config'}{'lazy'})
740 0 208 if ($e >= 0) { }
749 0 208 if ($begin =~ /$separator/o) { }
46 162 elsif ($begin =~ /$shortarg/ and defined($name = $self->{'long'}{$1}) and $self->{'flags'}{$name} & $arg) { }
65 97 elsif ($begin =~ /$shorts/o) { }
96 1 elsif ($begin =~ /$longex/) { }
760 38 8 $2 ne '' ? :
769 7 58 if $sign eq ""
771 30 35 defined $op ? :
772 30 35 defined $6 ? :
779 0 65 unless @{$names;}
788 65 4 $lastoption ? :
789 65 4 $lastoption ? :
792 69 0 if @{$self->{'errors'};} == $olderr
799 0 96 defined $7 ? :
800 2 94 if $sign eq ""
801 0 96 defined $8 ? :
804 86 10 defined $6 ? :
805 6 0 unless (exists $self->{'param'}{$name} or $self->{'config'}{'accept_unknown'})
807 0 6 if ($self->{'config'}{'fuzzy'}) { }
814 5 1 unless ($self->{'config'}{'ignore_unknown'} and $self->{'config'}{'ignore_unknown'} > 1)
822 0 96 unless ($name =~ /$noop$/o)
830 91 5 if @{$self->{'errors'};} == $olderr
832 91 5 if @{$self->{'errors'};} == $olderr
841 66 0 unless $self->{'bad_command_line'}
853 0 63 if ($olderr != $newerr)
871 0 1 if (not exists $self->{'param'}{$key} and defined $self->{'config'}{'accept_unknown'} and $self->{'config'}{'accept_unknown'} > 1)
877 143 1 if (exists $self->{'param'}{$key}) { }
0 1 elsif (not $self->{'config'}{'ignore_unknown'}) { }
887 62 0 unless $self->{'bad_command_line'}
896 40 27 if $self->{'config'}{'nofinals'}
899 11 16 unless defined $handle
904 0 0 $self->{'bad_config_file'} ? :
0 0 $self->{'bad_command_line'} ? :
0 27 @{$self->{'errors'};} ? :
908 0 27 if ($end)
910 0 0 if (@{$self->{'errors'};})
915 0 0 unless $self->{'config'}{'noexit'}
920 15 12 if ($self->{'param'}{'help'}) { }
0 12 elsif (defined $self->{'config'}{'version'} and $self->{'param'}{'version'}) { }
1 11 elsif ($self->{'printconfig'}) { }
924 0 15 unless $self->{'config'}{'noexit'}
930 0 0 unless $self->{'config'}{'noexit'}
936 0 1 unless $self->{'config'}{'noexit'}
950 71 0 unless defined $mk
952 68 3 if (not defined $format or $format eq 'dump') { }
3 0 elsif ($format eq 'lines') { }
954 68 0 if (eval { do { require Data::Dumper } }) { }
959 0 68 unless defined $Data::Dumper::Indent
968 0 3 unless defined $self->{$mk}{$k}
969 1 2 if ($self->{'type'}{$k} == $array) { }
1 1 elsif ($self->{'type'}{$k} == $hash) { }
971 0 1 unless @{$self->{$mk}{$k};}
991 48 0 unless defined $filler
993 36 6 $prefill && $indent - $prefill > 2 ? :
42 6 $indent > $prefill ? :
1003 0 87 unless @_
1016 0 87 unless @paragraphs
1026 3 128 if ($p =~ /^\t/) { }
33 95 elsif ($p eq '') { }
95 0 elsif ($can_wrap) { }
1028 0 3 if $llen
1036 27 6 unless defined $line
1049 220 1106 if (not $l or $l + $llen >= $length)
1056 1231 95 if ($l)
1058 1011 160 do { $llen } ? :
1171 60 defined $line ? :
1081 0 0 defined $line ? :
1103 0 4 unless defined $handle
1111 2 2 if defined $self->{'config'}{'info'}
1113 2 2 unless defined $tagline or not defined $prog
1118 1 3 unless (defined $usage or not @desc)
1120 1 0 if (lc($desc[0]) =~ /^\s*usage:\s*(.*\S?)\s*$/)
1122 0 1 if $1 ne ""
1127 1 0 if (not defined $usage and @desc)
1136 4 0 if (defined $prog)
1139 4 0 if defined $tagline
1142 2 2 if (defined $usage)
1147 1 3 if (@desc or defined $self->{'config'}{'infopod'})
1150 0 1 if (defined $self->{'config'}{'infopod'}) { }
1158 4 0 defined $prog ? :
1163 4 0 if ($self->{'config'}{'lazy'}) { }
1182 24 4 $self->{'short'}{$k} ne '' ? :
1185 4 24 $k eq 'help' ? :
1190 4 24 if $k eq "help"
1198 4 0 if defined $self->{'config'}{'extrapod'}
1204 8 4 if defined $self->{'config'}{$_->[1]}
1210 4 12 $ps->{'verbatim'} ? :
1223 0 0 $self->{'type'}{$k} == $scalar && ($self->{'flags'}{$k} & $switch || defined $self->{'arg'}{$k} && $self->{'arg'}{$k} eq '') && $self->{'default'}{$k} ? :
1231 0 15 unless defined $handle
1234 0 15 $self->{'config'}{'posixhelp'} ? :
1238 15 0 if (defined $self->{'config'}{'linewidth'}) { }
0 0 elsif (eval { do { require Term::ReadKey } }) { }
0 0 elsif (eval { do { require IPC::Run } }) { }
1246 0 0 if @s
1251 0 0 if (eval { do { IPC::Run::run(["tput", "cols"], \$in, \$linewidth, \$err) } })
1257 0 15 $linewidth > 80 ? :
1259 9 6 if ($self->{'param'}{'help'} =~ /^(-\d+),?(.*)$/)
1266 0 5 unless (exists $self->{'param'}{$_})
1273 0 9 if $badkeys
1275 1 8 if ($code == -1) { }
1 7 elsif ($code == -2) { }
1 6 elsif ($code == -3) { }
1 5 elsif ($code == -10) { }
1 4 elsif ($code == -11) { }
4 0 elsif ($code == -100) { }
1288 1 0 if @pars
1295 1 1 if ($first) { }
1318 0 6 if ($self->{'param'}{'help'} =~ /../)
1321 0 0 if (exists $self->{'param'}{$k}) { }
1328 0 0 unless defined $val
1330 0 0 $s ne '' ? :
0 0 $s ne '' ? :
0 0 $self->{'config'}{'posixhelp'} ? :
1341 0 0 $c eq $dc ? :
1346 0 0 if ($type eq $scalar) { }
0 0 elsif (grep {$_ == $type;} $array, $hash) { }
1349 0 0 if $flags & $switch or not $flags & $count
1351 0 0 if $flags & $count or not $flags & $switch
1353 0 0 $s ne '' ? :
0 0 $val ne '' ? :
0 0 $flags & $arg ? :
1369 0 0 unless $flags & $switch
1374 0 0 if not $flags & $switch and $s ne ""
1378 0 0 $s ne '' ? :
0 0 $s ne '' ? :
0 0 $s ne '' ? :
0 0 $s ne '' ? :
0 0 $flags & $count ? :
0 0 unless $flags & $arg
1392 0 0 $type == $hash ? :
1397 0 0 if $flags & $append
1400 0 0 $flags & $arg ? :
1407 0 0 if $flags & $append
1409 0 0 $flags & $arg ? :
0 0 if $s ne ""
1426 0 0 if $self->{'config'}{'lazy'}
1429 0 0 if (${$self->{'help'}{$k};} ne '') { }
1438 0 0 if $k eq "help"
1447 0 6 if ($self->{'param'}{'help'} =~ /\D/)
1453 0 6 defined $self->{'config'}{'version'} ? :
1454 3 3 if (defined $self->{'config'}{'tagline'}) { }
1457 1 2 if (defined $self->{'config'}{'usage'})
1462 1 2 if (defined $self->{'config'}{'info'}) { }
0 2 elsif (defined $self->{'config'}{'infopod'}) { }
1471 3 0 if defined $self->{'config'}{'copyright'}
1475 3 0 if (defined $self->{'config'}{'info'}) { }
0 0 elsif (defined $self->{'config'}{'infopod'}) { }
1485 3 0 if defined $self->{'config'}{'copyright'}
1491 0 6 if ($self->{'config'}{'posixhelp'}) { }
1502 6 0 if length $preprint > $indent
1509 6 0 if ($self->{'config'}{'lazy'}) { }
1512 2 4 if ($level > 1)
1522 2 4 if ($level > 1) { }
1536 0 6 if ($self->{'config'}{'ordered'}) { }
1540 0 0 if ($level >= $s->{'minlevel'})
1543 0 0 if $s->{'section'} ne ""
1545 0 0 if ${$s->{'help'};} ne ""
1564 0 6 if (@hidden_nonshort)
1567 0 0 if ($level > 1) { }
1574 0 0 @hidden_nonshort == 1 ? :
1580 0 6 if (@hidden_level)
1583 0 0 if ($level > 1) { }
1589 0 0 @hidden_level == 1 ? :
1606 0 0 if ($self->{'config'}{'hidenonshort'} and $self->{'short'}{$k} eq "" and not $k eq 'version' && defined $self->{'config'}{'version'})
1612 0 42 if ($level < $self->{'level'}{$k})
1618 0 42 if $hide
1620 0 42 if ($self->{'config'}{'posixhelp'}) { }
1641 36 6 if $self->{'short'}{$k} ne ""
1648 2 4 if $k eq "help" and $self->{'param'}{'help'} > 1 and defined $self->{'extrahelp'}
1652 42 10 $i == 0 ? :
1665 0 0 $self->{'short'}{$k} ne '' ? :
1669 0 0 if $k eq "help" and $self->{'param'}{'help'} > 1
1672 0 0 unless @help
1674 0 0 if $pm eq "+"
1678 0 0 $i == 0 ? :
1695 1 9 unless $self->parse_file($file, $construct)
1714 15 86 if "File::Spec"->file_name_is_absolute($name)
1719 2 84 if INT_filelike($name)
1720 0 84 if INT_filelike("$name.conf")
1725 0 84 if (defined $self->{'config'}{'confdir'}) { }
1745 555 11 unless INT_filelike($f)
1746 11 555 if (INT_filelike($f))
1753 11 73 if defined $path
1773 0 17 if (not defined $file) { }
0 17 elsif (grep {$_ eq $file;} @{$$self{'parse_chain'};}) { }
17 0 elsif ($cdat->open($file, '<')) { }
1775 0 0 unless $self->{'config'}{'nocomplain'}
1785 0 17 if (defined $self->{'config'}{'binmode'})
1800 35 263 if ($mcollect) { }
1802 140 123 if $_ =~ /^\s*#/ or $_ =~ /^\s*#?\s*$lend$/o
1804 39 84 if ($_ =~ /^=($nlend+)$lend*$/o) { }
1807 13 26 if ($construct)
1809 1 12 if ($meta =~ /^param file\s*(\(([^)]*)\)|)\s*for\s*(.+)$/) { }
0 12 elsif ($meta =~ /^version\s*(.+)$/) { }
0 12 elsif ($meta =~ /^info\s(.*)$/) { }
0 12 elsif ($meta =~ /^infopod\s(.*)$/) { }
1813 0 1 if (defined $2 and $2 =~ /^(.+)$/)
1818 0 0 if $s eq "eval"
1837 16 23 if ($meta =~ /^(long|key)\s*(\S*)(\s*short\s*(\S)|)(\s*type\s*(\S+)|)/) { }
16 7 elsif ($meta =~ /^(help|desc)\s(.*)$/) { }
5 2 elsif ($meta =~ /^include\s*(.+)$/) { }
1839 8 8 defined $4 ? :
1840 16 0 defined $6 ? :
1841 16 0 if (exists $typemap{$type}) { }
1850 0 16 $curpar{'help'} ne '' ? :
1858 5 0 unless ("File::Spec"->file_name_is_absolute($incfile))
1863 0 5 unless -e $incfile
1871 74 10 if ($_ =~ /^\s*($parname)\s*($lopex)\s*($nlend*)$lend$/) { }
0 10 elsif ($_ =~ /^\s*($parname)\s*$lend$/) { }
10 0 elsif ($_ =~ /^\s*($parname)\s*([$ops]?)<<(.*)$/) { }
1879 71 3 if (exists $self->{'param'}{$par}) { }
1886 1 2 unless ($self->{'config'}{'ignore_unknown'})
1888 0 1 if $self->{'config'}{'nanny'}
1897 0 0 if (exists $self->{'param'}{$par}) { }
1904 0 0 unless ($self->{'config'}{'ignore_unknown'})
1906 0 0 if $self->{'config'}{'nanny'}
1914 5 5 $2 ne '' ? :
1917 5 5 unless $mop =~ /=$/
1925 10 25 if ($_ =~ /^$ender$/) { }
1936 10 0 if (exists $self->{'param'}{$mkey}) { }
1944 0 0 unless ($self->{'config'}{'ignore_unknown'})
1946 0 0 if ($self->{'config'}{'nanny'})
1959 0 0 unless $self->{'config'}{'nocomplain'}
1961 16 1 if (@{$self->{'errors'};} == $olderrs) { }
1977 6 0 if (defined $curpar->{'long'} and $construct || $self->{'config'}{'accept_unknown'} && !exists $self->{'param'}{$par} && $curpar->{'long'} eq $par)
1989 0 3 if not exists $self->{'param'}{$par} and $construct || $self->{'config'}{'accept_unknown'}
1999 0 2 if defined $self->{'config'}{'version'}
2000 0 2 if defined $self->{'config'}{'notinfile'}
2001 2 0 unless ($bare)
2044 0 2 if @opt
2046 0 2 if defined $self->{'config'}{'version'}
2048 1 1 if (defined $self->{'config'}{'info'} and not $bare)
2053 0 2 if (defined $self->{'config'}{'infopod'} and not $bare)
2060 11 4 unless (grep /^$k$/, @omit)
2066 11 0 unless ($bare)
2069 8 3 $self->{'short'}{$k} ne '' ? :
2078 4 7 $self->{'type'}{$k} ? :
2079 2 9 if ($self->{'type'}{$k} == $hash)
2084 4 0 defined $values->{$k} ? :
2088 0 11 unless defined $values
2090 11 0 unless $bare
2096 4 0 @{$values;} > 1 ? :
8 4 !$first ? :
12 7 $self->{'type'}{$k} ? :
2098 18 1 if (defined $v) { }
2100 1 17 if ($v =~ /[\012\015]/) { }
2124 104 0 if (defined $k) { }
2139 0 280 unless exists $self->{'param'}{$_[0]}
2141 101 179 if ($self->{'type'}{$_[0]} == $scalar) { }
101 78 elsif ($self->{'type'}{$_[0]} == $array) { }
78 0 elsif ($self->{'type'}{$_[0]} == $hash) { }
2145 69 32 if ($_[1] eq '=') { }
6 26 elsif ($_[1] eq '.=') { }
10 16 elsif ($_[1] eq '+=') { }
11 5 elsif ($_[1] eq '-=') { }
5 0 elsif ($_[1] eq '*=') { }
0 0 elsif ($_[1] eq '/=') { }
2157 18 83 if ($_[1] eq '=') { }
54 29 elsif ($_[1] eq '.=') { }
3 26 elsif ($_[1] eq '//=' or $_[1] eq '/=' and $_[2] eq '/') { }
25 1 elsif ($_[1] =~ m[^/(.)/(.*)$]) { }
2165 11 14 if ($op eq '=') { }
14 0 elsif ($op eq '.=') { }
2170 1 100 if ($bad)
2181 25 53 if ($_[1] =~ m[^/(.)/(.*)$]) { }
3 50 elsif ($_[1] eq '//=' or $_[1] eq '/=' and $_[2] eq '/') { }
2187 11 14 if ($op eq '=') { }
14 0 elsif ($op eq '.=') { }
2196 12 38 if ($_[1] eq '=') { }
38 0 elsif ($_[1] eq '.=') { }
2200 0 78 if ($bad)
2215 64 76 if ($self->{'type'}{$k} == $scalar) { }
68 8 elsif ($self->{'type'}{$k} == $array) { }
8 0 elsif ($self->{'type'}{$k} == $hash) { }
2218 0 64 unless $p->{$k} =~ /$self->{'regex'}{$k}/
2224 2 13 unless $p->{$k}[$i] =~ /$self->{'regex'}{$k}/
2231 0 4 unless $p->{$k}{$n} =~ /$self->{'regex'}{$k}/
2239 321 16 unless $self->{'flags'}{$k} & $nonempty
2240 3 3 unless ($self->{'type'}{$k} == $scalar and $p->{$k} ne "" or $self->{'type'}{$k} == $array and @{$p->{$k};} or $self->{'type'}{$k} == $hash and %{$p->{$k};})
2260 6 18 if $bin->{$p}
2261 6 12 ref $self->{'param'}{$p} ? :
2274 62 144 unless defined $self->{'ops'}{$key}
2287 1381 0 unless $verbose or $self->{'config'}{'verbose'}
2295 0 14 unless $self->{'config'}{'silenterr'}