Branch Coverage

blib/lib/App/CSVUtils.pm
Criterion Covered Total %
branch 182 322 56.5


line true false branch
30 0 138 if ($filename eq '-') { }
33 0 138 unless (open $fh, "<", $filename)
48 0 2 if ($filename eq '-') { }
51 0 2 unless (open $fh, ">", $filename)
64 0 0 unless defined $filename
67 0 0 if ($filename eq '-') { }
70 0 0 if (-f $filename)
71 0 0 if ($overwrite) { }
77 0 0 unless (open my $fh, ">", $filename)
82 0 0 unless close $fh
88 2 43 if ref $_[0] eq "CODE"
90 0 43 unless defined $str and length $str
94 3 40 if $@
108 9 51 if ($return_topic) { }
118 0 0 unless defined $field and length $field
121 0 0 unless defined $idx
129 0 0 if $i == 1 and not $outputs_header
130 0 0 unless my $status = $csv->combine(@$row)
148 1 212 if (defined $$args{"${prefix}sep_char"} or defined $$args{"${prefix}quote_char"} or defined $$args{"${prefix}escape_char"}) { }
1 211 elsif ($$args{"${prefix}tsv"}) { }
151 1 0 if defined $$args{"${prefix}sep_char"}
152 0 1 if defined $$args{"${prefix}quote_char"}
153 0 1 if defined $$args{"${prefix}escape_char"}
159 1 212 if $$args{"${prefix}always_quote"}
160 0 213 if $$args{"${prefix}quote_empty"}
181 0 0 unless $cmdline
192 0 0 unless $r->{'config'}
197 0 0 unless defined $args and $args->{'input_filename'}
200 0 0 if $args->{'input_filename'} eq "-"
204 0 0 unless (open my $fh, "<encoding(utf8)", $args->{'input_filename'})
210 0 0 unless my $row = $csv_parser->getline($fh)
212 0 0 if (defined $args->{'input_header'} and not $args->{'input_header'})
216 0 0 if ($which =~ /sort/)
221 0 0 if ($which =~ /field_list/) { }
271 0 0 unless defined $val
272 0 0 unless Scalar::Util::Numeric::isnum($val)
285 15 14 if $field eq $name_or_idx
288 0 2 if ($name_or_idx eq '0') { }
1 1 elsif ($name_or_idx =~ /\A[1-9][0-9]*\z/) { }
0 1 elsif ($name_or_idx =~ /\A-[1-9][0-9]*\z/) { }
291 0 1 if ($name_or_idx > @$fields) { }
297 0 0 if (-$name_or_idx > @$fields) { }
317 4 8 if (defined $args->{'include_field_pat'})
320 10 0 if ($field =~ /$args->{'include_field_pat'}/)
325 1 11 if (defined $args->{'exclude_field_pat'})
330 8 4 if (defined $args->{'include_fields'})
334 4 9 unless (defined $field_idxs->{$field})
335 2 2 unless $args->{'ignore_unknown_fields'}
338 0 9 if grep {$field eq $_;} @selected_fields
342 2 8 if (defined $args->{'exclude_fields'})
346 0 2 unless (defined $field_idxs->{$field})
347 0 0 unless $args->{'ignore_unknown_fields'}
354 0 10 if (not $select_field_options_used and $default_select_choice)
355 0 0 if ($default_select_choice eq 'all') { }
0 0 elsif ($default_select_choice eq 'first') { }
0 0 elsif ($default_select_choice eq 'last') { }
0 0 elsif ($default_select_choice eq 'first-if-only-field') { }
358 0 0 if @$fields
360 0 0 if @$fields
362 0 0 if @$fields == 1
366 1 9 if ($args->{'show_selected_fields'})
984 0 42 if defined $args->{$argname}{'pos'}
989 503 6 unless $args->{$_}{'slurpy'}
995 0 42 if $is_slurpy and defined $slurpy_pos
1000 4 56 if defined $slurpy_pos and $j >= $slurpy_pos
1002 18 630 if defined $args->{$_}{'pos'} and $args->{$_}{'pos'} == $j
1005 3 35 if $is_slurpy
1405 0 25 unless my $name = delete $gen_args{'name'}
1416 3 22 if $reads_multiple_csv
1419 0 25 if $writes_multiple_csv
1431 0 25 if scalar keys %gen_args
1455 0 119 if ($util_args{'inplace'} and not $reads_csv && $writes_csv)
1459 37 82 if ($on_begin)
1466 79 132 unless ($r->{'output_filenames'})
1468 2 77 if ($util_args{'inplace'}) { }
0 77 elsif ($writes_multiple_csv) { }
1473 2 0 unless -e $output_filename
1485 3 76 unless $reads_csv and $writes_csv
1487 0 78 if $input_filename eq "-"
1489 0 78 unless $input_abs_path
1491 76 2 if $output_filename eq "-"
1492 0 2 if $seen_output_abs_path{$output_filename}
1494 0 2 unless $output_abs_path
1495 0 0 $output_filename ne $output_abs_path ? :
0 2 if $output_abs_path eq $input_abs_path
1508 79 132 if (not $r->{'output_fh'} or $r->{'wants_switch_to_next_output_file'})
1516 0 79 if ($r->{'output_fh'} and $r->{'output_filename'} ne "-")
1518 0 0 unless close $r->{'output_fh'}
1524 0 79 if $r->{'output_filenum'} > @{$r->{'output_filenames'};}
1529 77 2 if ($r->{'output_filename'} eq '-') { }
1532 0 2 if (-f $r->{'output_filename'})
1533 0 0 if ($r->{'util_args'}{'overwrite'}) { }
1540 0 2 if $err
1553 94 25 if ($writes_csv)
1560 24 178 unless ($r->{'output_fields'})
1566 75 127 unless ($r->{'output_fields_idx'})
1576 74 128 if ($outputs_header and not $r->{'has_printed_header'})
1591 202 0 if ($row)
1592 0 202 if (ref $row eq "HASH")
1608 0 119 if ($before_read_input)
1614 0 119 unless $reads_csv
1620 18 101 if ($reads_multiple_csv) { }
1635 1 137 if ($r->{'input_filenum'} == 1 and $before_open_input_files)
1638 0 1 if (delete $r->{'wants_skip_files'})
1644 0 138 if ($before_open_input_file)
1647 0 0 if (delete $r->{'wants_skip_file'}) { }
0 0 elsif (delete $r->{'wants_skip_files'}) { }
1659 0 138 if $err
1669 0 661 if ($r->{'stdin_input_fields'} and $r->{'input_filename'} eq '-') { }
4 657 elsif ($i == 0 and not $has_header) { }
4 1185 elsif ($i == 1 and not $has_header) { }
1670 0 0 if ($i == 0) { }
1678 0 0 if $row
1687 0 4 unless $row0
1691 4 0 if $row0
1695 537 116 if ($res)
1696 134 403 if $i == 0
1697 403 134 if $i
1707 527 18 $has_header ? :
1708 138 407 if ($i == 1) { }
1711 0 138 if $input_filename eq "-"
1718 124 14 if ($on_input_header_row)
1722 3 112 if (delete $r->{'wants_skip_file'}) { }
1 111 elsif (delete $r->{'wants_skip_files'}) { }
1743 407 0 unless (defined $r->{'wants_fill_rows'} and not $r->{'wants_fill_rows'})
1744 3 404 if (@{$r->{'input_row'};} < @{$r->{'input_fields'};})
1751 34 373 if ($r->{'wants_input_row_as_hashref'})
1755 0 93 if $j >= @{$r->{'input_fields'};}
1760 407 0 if ($on_input_data_row)
1761 123 284 if $r->{'input_rownum'} <= 2
1764 2 400 if (delete $r->{'wants_skip_file'}) { }
2 398 elsif (delete $r->{'wants_skip_files'}) { }
1778 0 116 if ($after_close_input_file)
1781 0 0 if (delete $r->{'wants_skip_files'})
1788 32 70 if ($after_close_input_files)
1810 15 90 if ($after_read_input)
1818 79 26 if ($r->{'output_fh'})
1819 2 77 if ($r->{'output_filename'} ne "-")
1821 0 2 unless close $r->{'output_fh'}
1825 2 103 if ($r->{'util_args'}{'inplace'})
1830 0 2 if $i > $output_filenum
1831 0 2 unless (my $input_filename = $output_filename) =~ s/\.\w{5}\z//
1833 1 1 if (length(my $ext = $r->{'util_args'}{'inplace_backup_ext'}))
1836 0 1 unless rename $input_filename, $backup_filename
1839 0 2 unless rename $output_filename, $input_filename
1852 11 94 if ($on_end)
1860 14 105 if ($err)
1861 0 14 unless ref $err
1866 91 14 if (not $r->{'result'}) { }
0 14 elsif (not ref $r->{'result'}) { }
0 14 elsif (ref $r->{'result'} ne 'ARRAY') { }
1892 25 0 if ($add_args)
1896 25 0 if ($reads_csv)
1899 3 22 if ($reads_multiple_csv) { }
1911 17 8 if ($writes_csv)
1914 17 0 if ($reads_csv)
1923 0 17 if ($writes_multiple_csv) { }
1926 0 0 if ($reads_csv)
1934 17 0 if ($reads_csv)
1951 3 22 if ($add_args_rels)
1956 0 25 if ($add_meta_props)