Branch Coverage

blib/lib/YAML/Tidy.pm
Criterion Covered Total %
branch 256 300 85.3


line true false branch
25 0 12 $ENV{'YAML_TIDY_DEBUG'} ? :
46 2866 12 if (@lines)
48 2695 171 if $self->cfg->trimtrailing
59 934 20439 if ($node->{'flow'})
66 0 20439 unless @$lines
68 3171 17268 if ($level == -1 and $type eq "DOC")
78 17573 2866 $parent ? :
82 0 20439 unless (defined $line)
88 9821 10618 if ($node->is_collection) { }
90 6038 3783 if ($level < 0 or $ignore_firstlevel)
97 2165 1618 if ($level == 0)
100 2379 1404 if ($type eq 'MAP') { }
1404 0 elsif ($type eq 'SEQ') { }
101 311 2068 if ($before =~ tr/ //c)
102 0 311 if ($indent == 1)
108 235 1169 if ($before =~ tr/ //c) { }
109 0 235 if ($indent == 1)
114 358 811 if ($parent->{'type'} eq "MAP" and not $node->{'index'} % 2)
122 544 3239 if ($diff)
132 682 9936 if (defined(my $anchor = $node->{'anchor'}))
137 266 10352 if ($node->empty_leaf)
140 261 10091 if ($node->is_alias)
144 0 10091 if ($node->{'name'} eq "alias_event")
147 4206 3219 if ($parent->{'type'} eq "MAP" and ($node->{'index'} % 2 and not $node->multiline))
156 847 5038 if ($scalar->[2] =~ /[>|]/u)
163 5064 821 if ($before =~ tr/\t //c)
166 5064 0 if $before =~ s/([\t ]+)$/ /u
168 3960 1104 unless ($node->multiline)
176 5883 2 unless ($ignore_firstlevel)
179 5331 694 if ($i == $startline and $col > 0)
181 5064 267 if ($before =~ tr/ //c)
185 0 961 unless ($line =~ tr/ //c)
189 961 0 if $line =~ s/^( *)/$new_spaces/u
190 819 142 if ($i == $startline)
192 387 432 unless ($node->multiline)
200 146 5739 if $explicit_indent
215 701 5038 if ($block) { }
5038 0 elsif ($node->{'style'} == 1 or $node->{'style'} == 2 or $node->{'style'} == 3) { }
219 63 5 if ($trimtrailing)
224 63 638 if ($nextline > $endline + 1)
229 344 357 if (not $ignore_firstlevel and length $sp != $new_indent) { }
332 25 elsif ($trimtrailing) { }
231 262 837 unless (length $line)
234 122 715 if (not $line =~ tr/ //c and length $line <= length $sp)
235 114 8 if ($trimtrailing)
240 31 684 if ($line =~ /^( *)\#/u) { }
244 31 0 if ($diff > 0) { }
0 0 elsif ($diff < 0) { }
248 0 0 if ($cindent < 0)
263 204 648 if (not $line =~ tr/ //c and length $line <= length $sp)
273 0 5038 if ($node->empty_leaf)
277 1078 3960 if (not $skipfirst or $node->multiline)
279 369 709 if $skipfirst
281 0 1078 if $startline >= @$lines
284 1 1077 if ($ignore_firstlevel)
289 0 1078 if ($level == 0 and not $indenttoplevelscalar)
293 1650 283 if ($line =~ tr/ //c)
294 1650 0 if $line =~ s/^([\t ]*)/$new_spaces/u
301 4347 691 if (not $node->multiline)
322 827 9986 if $node->{'tag'}
325 1539 8447 if (defined $default_style and $node->{'style'} != $default_style)
327 1360 179 if ($changed)
331 59 1301 if (defined $node->{'anchor'} or $node->{'tag'})
337 1333 27 if ($diff)
349 152 1387 if (grep {$_ eq $value;} @all or $value =~ /($re)/u)
351 151 1 if ($node->{'style'} eq 1 or $style eq 1)
358 0 1388 if $emit =~ tr/\n//
360 665 47 $first eq '"' ? :
676 712 $first eq q['] ? :
364 1360 28 if ($new_style eq $style)
377 325 1063 if ($inflow)
383 325 1063 if ($inflow)
391 325 1063 if ($inflow)
399 15 34 if ($node->is_alias) { }
405 7 27 if (defined(my $anchor = $node->{'anchor'}))
409 11 23 if ($node->is_collection)
422 0 2 if $anchors->{$name} < 2
436 15 2 if ($anchor ne $new_anchor)
449 706 7 unless my $usage = $self->{'doc'}{'anchors'}{$group}
451 0 7 unless @$usage
453 7 0 if ($new_anchor ne $group)
460 263 10 unless my $new_anchor = $self->{'doc'}{'rename'}{$anchor}
462 10 0 if ($new_anchor ne $group)
470 2 3169 if ($self->cfg->serialize_aliases)
476 346 2825 if ($node->open->{'implicit'} and $self->cfg->addheader and not $self->partial) { }
159 3409 elsif ($node->{'index'} == 1 and not $open->{'implicit'} and $self->cfg->removeheader and not $self->partial) { }
489 21 138 if ($open->{'version_directive'} or $open->{'tag_directives'} or not $child->is_collection and $child->empty_leaf) { }
494 99 39 if ($line =~ /^---[ \t]*$/u) { }
0 39 elsif ($line =~ s/^---[ \t]+(?=#)//u) { }
507 531 2640 if ($close->{'implicit'} and $self->cfg->addfooter and not $self->partial) { }
27 2724 elsif (not $close->{'implicit'} and $self->cfg->removefooter and not $self->partial) { }
518 15 12 if ($next and $next->open->{'version_directive'} || $next->open->{'tag_directives'}) { }
523 12 0 if ($line =~ /^\.\.\.[ \t]*$/u) { }
0 0 elsif ($line =~ s/^\.\.\.[ \t]+(?=#)//u) { }
538 10576 12584 if ($node->is_collection) { }
12340 244 elsif (defined $node->{'style'}) { }
543 5677 4899 if ($level == -1)
549 793 11547 if ($node->{'style'} eq 4 or $node->{'style'} eq 5)
559 0 3832 unless $parent
563 213 3619 if $level == 0
565 31 3801 if (defined(my $anchor = $node->{'anchor'}))
568 12 3820 if ($node->is_alias)
572 2491 1341 unless ($node->is_collection)
576 92 1249 if ($parent->{'type'} eq "MAP" and $node->{'index'} % 2)
585 882 367 if ($before =~ tr/\t //c)
590 279 970 unless ($before_end =~ tr/\t //c)
606 121 2370 if ($node->empty_leaf)
614 2028 342 if ($before =~ tr/\t //c)
623 398 42 if ($block_indent != $old)
628 2272 98 if (not $node->multiline)
630 2260 12 if ($node->{'name'} eq "scalar_event")
637 0 2272 unless $node->{'flow'}
638 1545 727 unless $node->is_mapping_value($parent)
643 507 180 unless ($prev->is_collection or $prev->is_quoted)
649 60 667 if ($start->{'column'} > 0 and substr($line, $start->{'column'} - 1, 1) eq ":")
652 214 513 unless defined $tidy_adjacency
653 0 513 if ($tidy_adjacency)
656 504 9 unless $adjacent
678 6737 156 $i == 0 ? :
679 4484 2409 $i == $#slice ? :
681 0 6893 if ($part =~ /^ *(\#.*)$/gu)
695 485 806 if ($type eq '&') { }
806 0 elsif ($type eq '!') { }
703 0 6893 if ($part =~ /\G *(\#.*)$/gu)
711 6570 323 if ($part =~ /\G *(\S)/gu)
737 20 1360 unless length $line
738 875 485 if ($fix < 0) { }
741 0 875 if ($offset > length $line)
744 875 0 if ($line =~ tr/ //c) { }
745 22 853 if ($line =~ /^ *\#/u)
759 0 485 unless ($line =~ tr/ //c)
765 2 483 if ($offset > 0 and $line =~ /^ {0,$offset1}\#/u)
803 3171 26885 if ($name =~ /document_start/u) { }
2104 24781 elsif ($name =~ /sequence_start/u) { }
3081 21700 elsif ($name =~ /mapping_start/u) { }
273 21427 elsif ($name eq 'alias_event') { }
817 8356 21700 if ($name =~ /_start_event/u) { }
8356 13344 elsif ($name =~ /_end_event/u) { }
273 13071 elsif ($name eq 'alias_event') { }
819 2104 6252 if ($name eq "sequence_start_event")
822 1402 702 if ($col > 0)
825 117 1285 if ($chr eq "-")
830 934 6955 if ($flow or ($event->{'style'} // -1) == 2 or ($event->{'style'} // -1) == 2)
857 1401 6955 if $flow
874 27214 2842 if ($i < $events->$#*)
906 0 0 if ($name =~ /scalar|alias/u) { }
0 0 elsif ($name =~ /end/u) { }
930 200 5530 if ($error)
934 0 600 if ($line =~ s/( +\n)//u)
942 0 5730 if ($type eq "html")