Branch Coverage

blib/lib/YAML/Tidy.pm
Criterion Covered Total %
branch 224 258 86.8


line true false branch
25 0 6 $ENV{'YAML_TIDY_DEBUG'} ? :
46 3024 13 if (@lines)
48 2856 168 if $self->cfg->trimtrailing
59 975 21449 if ($node->{'flow'})
66 0 21449 unless @$lines
68 3347 18102 if ($level == -1 and $type eq "DOC")
78 18425 3024 $parent ? :
82 0 21449 unless (defined $line)
88 10329 11120 if ($node->is_collection) { }
90 6372 3957 if ($level < 0 or $ignore_firstlevel)
97 2274 1683 if ($level == 0)
100 2492 1465 if ($type eq 'MAP') { }
1465 0 elsif ($type eq 'SEQ') { }
101 317 2175 if ($before =~ tr/ /\000-\037!-\377/c)
102 12 305 if ($indent == 1)
108 247 1218 if ($before =~ tr/ /\000-\037!-\377/c) { }
109 12 235 if ($indent == 1)
114 370 848 if ($parent->{'type'} eq "MAP" and not $node->{'index'} % 2)
122 588 3369 if ($diff)
133 282 10838 if ($node->empty_scalar)
136 261 10577 if ($node->{'name'} eq "alias_event")
139 4395 3385 if ($parent->{'type'} eq "MAP" and ($node->{'index'} % 2 and not $node->multiline))
148 901 5281 if ($scalar->[2] =~ /[>|]/u)
155 5311 871 if ($before =~ tr/\t /\000-\b\n-\037!-\377/c)
158 5311 0 if $before =~ s/([\t ]+)$/ /u
160 4140 1171 unless ($node->multiline)
168 6180 2 unless ($ignore_firstlevel)
171 5591 740 if ($i == $startline and $col > 0)
173 5311 280 if ($before =~ tr/ /\000-\037!-\377/c)
177 0 1020 unless ($line =~ tr/ /\000-\037!-\377/c)
181 1020 0 if $line =~ s/^( *)/$new_spaces/u
182 869 151 if ($i == $startline)
184 409 460 unless ($node->multiline)
192 155 6027 if $explicit_indent
207 746 5281 if ($block) { }
5281 0 elsif ($node->{'style'} == 1 or $node->{'style'} == 2 or $node->{'style'} == 3) { }
211 68 5 if ($trimtrailing)
216 68 678 if ($nextline > $endline + 1)
221 373 373 if (not $ignore_firstlevel and length $sp != $new_indent) { }
348 25 elsif ($trimtrailing) { }
223 274 905 unless (length $line)
226 132 773 if (not $line =~ tr/ /\000-\037!-\377/c and length $line <= length $sp)
227 124 8 if ($trimtrailing)
232 42 731 if ($line =~ /^( *)\#/u) { }
236 31 11 if ($diff > 0) { }
11 0 elsif ($diff < 0) { }
240 0 11 if ($cindent < 0)
255 228 689 if (not $line =~ tr/ /\000-\037!-\377/c and length $line <= length $sp)
265 0 5281 if ($node->empty_scalar)
269 1141 4140 if (not $skipfirst or $node->multiline)
271 391 750 if $skipfirst
273 0 1141 if $startline >= @$lines
276 1 1140 if ($ignore_firstlevel)
281 0 1141 if ($level == 0 and not $indenttoplevelscalar)
285 1747 301 if ($line =~ tr/ /\000-\037!-\377/c)
286 1747 0 if $line =~ s/^([\t ]*)/$new_spaces/u
293 4549 732 if (not $node->multiline)
314 875 10419 if $node->{'tag'}
317 1508 8911 if (defined $default_style and $node->{'style'} != $default_style)
319 1341 167 if ($changed)
323 58 1283 if (defined $node->{'anchor'} or $node->{'tag'})
329 1314 27 if ($diff)
341 150 1358 if (grep {$_ eq $value;} @all or $value =~ /($re)/u)
343 149 1 if ($node->{'style'} eq 1 or $style eq 1)
350 0 1359 if $emit =~ tr/\n//
352 668 30 $first eq '"' ? :
661 698 $first eq q['] ? :
356 1341 18 if ($new_style eq $style)
380 339 3008 if ($node->open->{'implicit'} and $self->cfg->addheader and not $self->partial) { }
159 3645 elsif ($node->{'index'} == 1 and not $open->{'implicit'} and $self->cfg->removeheader and not $self->partial) { }
393 21 138 if ($open->{'version_directive'} or $open->{'tag_directives'} or not $child->is_collection and $child->empty_scalar) { }
398 99 39 if ($line =~ /^---[ \t]*$/u) { }
0 39 elsif ($line =~ s/^---[ \t]+(?=#)//u) { }
411 531 2816 if ($close->{'implicit'} and $self->cfg->addfooter and not $self->partial) { }
27 2909 elsif (not $close->{'implicit'} and $self->cfg->removefooter and not $self->partial) { }
422 15 12 if ($next and $next->open->{'version_directive'} || $next->open->{'tag_directives'}) { }
427 12 0 if ($line =~ /^\.\.\.[ \t]*$/u) { }
0 0 elsif ($line =~ s/^\.\.\.[ \t]+(?=#)//u) { }
442 11171 13244 if ($node->is_collection) { }
12988 256 elsif (defined $node->{'style'}) { }
447 6017 5154 if ($level == -1)
453 847 12141 if ($node->{'style'} eq 4 or $node->{'style'} eq 5)
463 0 3996 unless $parent
467 226 3770 if $level == 0
469 2591 1405 unless ($node->is_collection)
473 97 1308 if ($parent->{'type'} eq "MAP" and $node->{'index'} % 2)
482 919 389 if ($before =~ tr/\t /\000-\b\n-\037!-\377/c)
487 294 1014 unless ($before_end =~ tr/\t /\000-\b\n-\037!-\377/c)
503 128 2463 if ($node->empty_scalar)
511 2101 362 if ($before =~ tr/\t /\000-\b\n-\037!-\377/c)
520 415 51 if ($block_indent != $old)
525 2359 104 if (not $node->multiline)
527 2350 9 if ($node->{'name'} eq "scalar_event")
534 0 2359 unless $node->{'flow'}
535 1610 749 unless $node->is_mapping_value($parent)
540 527 180 unless ($prev->is_collection or $prev->is_quoted)
546 56 693 if ($start->{'column'} > 0 and substr($line, $start->{'column'} - 1, 1) eq ":")
549 222 527 unless defined $tidy_adjacency
550 0 527 if ($tidy_adjacency)
553 525 2 unless $adjacent
575 7087 166 $i == 0 ? :
576 4690 2563 $i == $#slice ? :
578 0 7253 if ($part =~ /^ *(\#.*)$/gu)
592 501 853 if ($type eq '&') { }
853 0 elsif ($type eq '!') { }
600 0 7253 if ($part =~ /\G *(\#.*)$/gu)
608 6911 342 if ($part =~ /\G *(\S)/gu)
634 19 1430 unless length $line
635 953 477 if ($fix < 0) { }
638 0 953 if ($offset > length $line)
641 953 0 if ($line =~ tr/ /\000-\037!-\377/c) { }
642 18 935 if ($line =~ /^ *\#/u)
656 0 477 unless ($line =~ tr/ /\000-\037!-\377/c)
694 3347 28160 if ($name =~ /document_start/u) { }
2203 25957 elsif ($name =~ /sequence_start/u) { }
3224 22733 elsif ($name =~ /mapping_start/u) { }
705 8774 22733 if ($name =~ /_start_event/u) { }
8774 13959 elsif ($name =~ /_end_event/u) { }
707 2203 6571 if ($name eq "sequence_start_event")
710 1469 734 if ($col > 0)
713 121 1348 if ($chr eq "-")
718 975 7305 if ($flow or ($event->{'style'} // -1) == 2 or ($event->{'style'} // -1) == 2)
745 1469 7305 if $flow
755 28509 2998 if ($i < $#$events)
787 0 0 if ($name =~ /scalar|alias/u) { }
0 0 elsif ($name =~ /end/u) { }
811 242 5826 if ($error)
815 0 694 if ($line =~ s/( +\n)//u)
823 0 6068 if ($type eq "html")