Branch Coverage

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


line true false branch
30 0 129 if ($filename eq '-') { }
33 0 129 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 1 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 194 if (defined $$args{"${prefix}sep_char"} or defined $$args{"${prefix}quote_char"} or defined $$args{"${prefix}escape_char"}) { }
1 193 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 194 if $$args{"${prefix}always_quote"}
160 0 195 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 40 if defined $args->{$argname}{'pos'}
989 491 6 unless $args->{$_}{'slurpy'}
995 0 40 if $is_slurpy and defined $slurpy_pos
1000 4 53 if defined $slurpy_pos and $j >= $slurpy_pos
1002 17 629 if defined $args->{$_}{'pos'} and $args->{$_}{'pos'} == $j
1005 3 33 if $is_slurpy
1392 0 24 unless my $name = delete $gen_args{'name'}
1403 3 21 if $reads_multiple_csv
1406 0 24 if $writes_multiple_csv
1418 0 24 if scalar keys %gen_args
1442 0 110 if ($util_args{'inplace'} and not $reads_csv && $writes_csv)
1446 37 73 if ($on_begin)
1453 70 114 unless ($r->{'output_filenames'})
1455 2 68 if ($util_args{'inplace'}) { }
0 68 elsif ($writes_multiple_csv) { }
1460 2 0 unless -e $output_filename
1472 3 67 unless $reads_csv and $writes_csv
1474 0 78 if $input_filename eq "-"
1476 0 78 unless $input_abs_path
1478 76 2 if $output_filename eq "-"
1479 0 2 if $seen_output_abs_path{$output_filename}
1481 0 2 unless $output_abs_path
1482 0 0 $output_filename ne $output_abs_path ? :
0 2 if $output_abs_path eq $input_abs_path
1495 70 114 if (not $r->{'output_fh'} or $r->{'wants_switch_to_next_output_file'})
1503 0 70 if ($r->{'output_fh'} and $r->{'output_filename'} ne "-")
1505 0 0 unless close $r->{'output_fh'}
1511 0 70 if $r->{'output_filenum'} > @{$r->{'output_filenames'};}
1516 68 2 if ($r->{'output_filename'} eq '-') { }
1519 0 2 if (-f $r->{'output_filename'})
1520 0 0 if ($r->{'util_args'}{'overwrite'}) { }
1527 0 2 if $err
1540 85 25 if ($writes_csv)
1547 24 151 unless ($r->{'output_fields'})
1553 66 109 unless ($r->{'output_fields_idx'})
1563 65 110 if ($outputs_header and not $r->{'has_printed_header'})
1578 175 0 if ($row)
1579 0 175 if (ref $row eq "HASH")
1595 0 110 if ($before_read_input)
1601 0 110 unless $reads_csv
1607 18 92 if ($reads_multiple_csv) { }
1622 1 128 if ($r->{'input_filenum'} == 1 and $before_open_input_files)
1625 0 1 if (delete $r->{'wants_skip_files'})
1631 0 129 if ($before_open_input_file)
1634 0 0 if (delete $r->{'wants_skip_file'}) { }
0 0 elsif (delete $r->{'wants_skip_files'}) { }
1646 0 129 if $err
1656 0 562 if ($r->{'stdin_input_fields'} and $r->{'input_filename'} eq '-') { }
4 558 elsif ($i == 0 and not $has_header) { }
4 996 elsif ($i == 1 and not $has_header) { }
1657 0 0 if ($i == 0) { }
1665 0 0 if $row
1674 0 4 unless $row0
1678 4 0 if $row0
1682 447 107 if ($res)
1683 125 322 if $i == 0
1684 322 125 if $i
1694 437 18 $has_header ? :
1695 129 326 if ($i == 1) { }
1698 0 129 if $input_filename eq "-"
1705 115 14 if ($on_input_header_row)
1709 3 103 if (delete $r->{'wants_skip_file'}) { }
1 102 elsif (delete $r->{'wants_skip_files'}) { }
1730 326 0 unless (defined $r->{'wants_fill_rows'} and not $r->{'wants_fill_rows'})
1731 3 323 if (@{$r->{'input_row'};} < @{$r->{'input_fields'};})
1738 34 292 if ($r->{'wants_input_row_as_hashref'})
1742 0 93 if $j >= @{$r->{'input_fields'};}
1747 326 0 if ($on_input_data_row)
1748 114 212 if $r->{'input_rownum'} <= 2
1751 2 319 if (delete $r->{'wants_skip_file'}) { }
2 317 elsif (delete $r->{'wants_skip_files'}) { }
1765 0 107 if ($after_close_input_file)
1768 0 0 if (delete $r->{'wants_skip_files'})
1775 32 61 if ($after_close_input_files)
1797 6 90 if ($after_read_input)
1805 70 26 if ($r->{'output_fh'})
1806 2 68 if ($r->{'output_filename'} ne "-")
1808 0 2 unless close $r->{'output_fh'}
1812 2 94 if ($r->{'util_args'}{'inplace'})
1817 0 2 if $i > $output_filenum
1818 0 2 unless (my $input_filename = $output_filename) =~ s/\.\w{5}\z//
1820 1 1 if (length(my $ext = $r->{'util_args'}{'inplace_backup_ext'}))
1823 0 1 unless rename $input_filename, $backup_filename
1826 0 2 unless rename $output_filename, $input_filename
1839 11 85 if ($on_end)
1847 14 96 if ($err)
1848 0 14 unless ref $err
1853 82 14 if (not $r->{'result'}) { }
0 14 elsif (not ref $r->{'result'}) { }
0 14 elsif (ref $r->{'result'} ne 'ARRAY') { }
1879 24 0 if ($add_args)
1883 24 0 if ($reads_csv)
1886 3 21 if ($reads_multiple_csv) { }
1898 16 8 if ($writes_csv)
1901 16 0 if ($reads_csv)
1910 0 16 if ($writes_multiple_csv) { }
1913 0 0 if ($reads_csv)
1921 16 0 if ($reads_csv)
1938 3 21 if ($add_args_rels)
1943 0 24 if ($add_meta_props)