Branch Coverage

blib/lib/JSON/Schema/Modern.pm
Criterion Covered Total %
branch 266 320 83.1


line true false branch
123 0 11 if exists(($$self{"_format_validations"} // {})->{$format})
125 6 5 if ref $definition ne "HASH"
130 1 3 if core_formats_type()->check($format) and $$definition{"type"} ne "string"
158 0 17394 if @_ < 2
161 1 17393 if ($_[0]->$_isa("JSON::Schema::Modern::Document"))
167 0 17360 $_[0]->$_isa('Mojo::URL') ? :
33 17360 !is_schema($_[0]) ? :
170 1 17392 if defined $uri->fragment
171 0 17392 unless @_
173 1 17391 if ($_[0]->$_isa("JSON::Schema::Modern::Document"))
189 12302 5089 if (my $existing_doc = &first(sub { my $existing_checksum = $_->_checksum // $_->_checksum(md5($self->_json_decoder->encode($_->schema))); $_->canonical_uri eq $document->canonical_uri if $existing_checksum eq $schema_checksum; } , &uniqint(map($our $_{"document"}, $self->_canonical_resources))))
192 12302 705706 if $existing_checksum eq $schema_checksum
203 0 18203 if @_ < 2
207 0 10 $_[0]->$_isa('Mojo::URL') ? :
18193 10 !$_[0]->$_isa('JSON::Schema::Modern::Document') ? :
210 0 18203 if defined $base_uri->fragment
211 0 18203 unless @_
214 0 18203 unless $document->$_isa("JSON::Schema::Modern::Document")
217 180 18023 if $document->has_errors
224 17190 833 unless (length $base_uri)
253 73 96 $our $_[1] ? :
259 826 30 if $$new_resource{"path"} eq "" and not $uri_string =~ /#./u
263 64 762 if $root[0] ne $base_uri
269 0 3 unless defined wantarray
303 0 17943 if keys %overrides
312 0 17943 unless $initial_path =~ m[^(?:/|\z)]u
314 4 17939 if (length(my $uri_path = $initial_uri->fragment))
315 0 4 unless $uri_path =~ m[^/]u
317 0 4 if substr($initial_path, -length($uri_path)) ne $uri_path
333 69 17874 $$config_override{'skip_ref_checks'} ? :
346 5932 12011 ref $schema_reference eq 'HASH' && exists $$schema_reference{'$schema'} ? :
348 17937 6 if (my $metaschema_info = $self->_get_metaschema_vocabulary_classes($$state{'metaschema_uri'})) { }
355 0 6 unless $$config_override{"metaschema_uri"}
362 17939 4 if $valid and not @{$$state{"errors"}}
363 0 165 unless $valid or @{$$state{"errors"}}
364 0 17943 if $valid and @{$$state{"errors"}}
367 0 0 if ($e->$_isa('JSON::Schema::Modern::Result')) { }
0 0 elsif ($e->$_isa('JSON::Schema::Modern::Error')) { }
384 0 17390 unless defined wantarray
388 0 17390 if keys %overrides
400 10765 6625 ref $data ? :
404 17315 75 if (is_schema($schema_reference)) { }
4 135 elsif (ref $schema_reference and not $schema_reference->$_isa('Mojo::URL')) { }
413 6 17195 unless $schema_info
417 1 17194 unless $$schema_info{"document"}->get_entity_at_location($$schema_info{"document_path"})
430 68446 51912 defined $val ? :
433 10 17184 $$config_override{'with_defaults'} // $self->with_defaults ? :
437 5 17189 if $$config_override{"_strict_schema_data"}
446 0 7524 unless $valid or @{$$state{"errors"}}
447 0 17171 if $valid and @{$$state{"errors"}}
450 180 39 if ($e->$_isa('JSON::Schema::Modern::Result')) { }
34 5 elsif ($e->$_isa('JSON::Schema::Modern::Error')) { }
461 5 17205 if ($$state{"seen_data_properties"})
472 7 1 @{$unknown_keywords{$parent}} > 1 ? :
476 0 17210 if $valid xor not @{$$state{"errors"}}
488 28 9615 $$config_override{'collect_annotations'} // $self->collect_annotations ? :
9643 7567 $valid ? :
10 17200 $$state{'defaults'} ? :
492 0 10 unless defined wantarray
495 6 4 ref $schema eq 'HASH' && $$schema{'$schema'} ? :
498 5 5 $self->strict || $$config_override{'strict'} ? :
500 7 3 unless $result->valid
508 1 2 if @{$$state{"errors"}}
514 5 3 if (wantarray) { }
516 1 4 unless $schema_info
517 3 1 ref $$schema_info{'schema'} ? :
521 3 0 unless ref $uri_reference
524 0 3 unless $resource
527 2 1 if (not length $fragment or $fragment =~ m[^/]u) { }
531 1 0 unless my $subresource = ($$resource{"anchors"} // {})->{$fragment}
534 1 1 ref $schema ? :
540 0 0 unless $schema_info
594 0 42172 if $$state{"depth"}++ > $self->max_depth
601 7710 8 if $schema_type eq "boolean" and $$state{'specification_version'} ne 'draft4' || $$state{'keyword_path'} =~ m[/(?:additional(?:Items|Properties)|uniqueItems)\z]u
603 17 34445 if $schema_type ne "object"
605 1199 33246 unless keys %$schema
629 1627964 56872 unless exists $$schema{$keyword}
632 36 53523 if $keyword ne "\$ref" and exists $$schema{"\$ref"} and $$state{"specification_version"} =~ /^draft[467]\z/u
640 243 56593 unless (&$sub($vocabulary, $schema, $state))
642 0 243 if $error_count == @{$$state{"errors"}}
647 0 56593 if $error_count != @{$$state{"errors"}}
650 68 56525 if $$state{"specification_version"} ne $old_spec_version
652 4 56589 if (my $callback = $$state{"callbacks"}{$keyword})
655 0 4 unless (&$callback($schema, $state))
657 0 0 if $error_count == @{$$state{"errors"}}
662 0 4 if $error_count != @{$$state{"errors"}}
669 2 81 if ($self->strict and keys %unknown_keywords)
670 2 0 keys %unknown_keywords > 1 ? :
676 103826 224 unless exists $$schema{$keyword}
679 224 0 if (my $alternates = $removed_keywords{$$state{"specification_version"}}{$keyword})
681 0 224 if @list > 2
682 167 57 if @list > 1
692 0 34834 unless defined wantarray
700 3 34831 if $$state{"depth"}++ > $self->max_depth
703 844 33987 if $schema_type eq "boolean"
706 0 33987 if $schema_type ne "object"
708 638 33349 unless keys %$schema
718 1 33348 if grep((substr($schema_location, 0, length $_) eq $_), keys %{$$state{"seen"}{$$state{"data_path"}}{$canonical_uri}})
740 52 33296 if $$state{"defaults"}
762 1450119 60037 unless exists $$schema{$keyword}
765 31 56365 if $keyword ne "\$ref" and exists $$schema{"\$ref"} and $$state{"specification_version"} =~ /^draft[467]\z/u
768 1 1840 if not $valid and $$state{"short_circuit"} and $$state{"strict"}
772 55929 4076 if ($sub)
777 13161 42724 unless (&$sub($vocabulary, $data, $schema, $state))
779 0 13161 if $error_count == @{$$state{"errors"}}
782 6213 6948 if $$state{"short_circuit"} and not $$state{"strict"}
787 0 42724 if $error_count != @{$$state{"errors"}}
790 42 2 if $e->$_isa("JSON::Schema::Modern::Error")
795 3 42721 if $$state{"specification_version"} ne $old_spec_version
798 24 46776 if (my $callback = ($$state{"callbacks"} // {})->{$keyword})
801 2 22 unless (&$callback($data, $schema, $state))
803 0 2 if $error_count == @{$$state{"errors"}}
806 1 1 if $$state{"short_circuit"} and not $$state{"strict"}
810 0 22 if $error_count != @{$$state{"errors"}}
817 3 197 if ($$state{"strict"} and keys %unknown_keywords)
818 1 2 keys %unknown_keywords > 1 ? :
824 156 33145 if ($$state{"seen_data_properties"} and $is_object_data)
832 287 290 grep(($keyword eq $_), ('properties', 'additionalProperties', 'patternProperties', 'unevaluatedProperties')) ? :
840 2 154 if exists $$data{"\$ref"} and $$state{"specification_version"} eq "draft4"
843 969 19337 if ($valid and $$state{"collect_annotations"} and not $$state{"specification_version"} =~ /^draft(?:[467]|2019-09)\z/u)
849 20306 12995 if $valid
853 41 33260 if $valid and $$state{"defaults"}
877 0 44037 if $_[1] =~ /#/u
895 17056 1922 if (my $existing = $self->_get_resource($canonical_uri)) { }
2 1920 elsif (JSON::Schema::Modern::Utilities::get_schema_filename($canonical_uri)) { }
898 859 16197 if ($canonical_uri ne "")
903 856 3 $$existing{'path'} eq $$resource{'path'} ? :
856 3 $$existing{'canonical_uri'} eq $$resource{'canonical_uri'} ? :
859 0 $$existing{'specification_version'} eq $$resource{'specification_version'} ? :
849 10 builtin::refaddr($$existing{'document'}) == builtin::refaddr($$resource{'document'}) ? :
904 849 10 unless @diffs
941 0 10 if grep(($our $_[1] eq $classname), values %{$self->__vocabulary_classes})
951 1 3 if grep /^\$/u, $classname->keywords
990 2 51 unless (exists $$schema_info{"schema"}{"\$vocabulary"})
1000 1 50 if length $$schema_info{"document_path"}
1001 1 50 unless exists $$schema_info{"schema"}{"\$id"}
1003 2 49 unless $valid
1010 8 97 if $$schema_info{"schema"}{"\$vocabulary"}{$uri} and not $class_info
1012 8 89 unless $class_info
1017 6 83 if $spec_version ne $$schema_info{"specification_version"}
1023 0 1 $a->evaluation_order == 999 ? :
0 48 unless $a->evaluation_order <=> $b->evaluation_order
1028 9 40 if ($vocabulary_classes[0] // "") ne "JSON::Schema::Modern::Vocabulary::Core"
1036 1 793 if $seen_keyword{$keyword}
1041 32 17 $valid ? :
1094 24314 114 if $resource
1096 103 11 if (my $document = load_cached_document($self, $uri))
1115 127 24063 unless ref $uri_reference
1119 11 24179 unless $resource
1122 23599 580 if (not length $fragment or $fragment =~ m[^/]u) { }
1124 2 23597 unless defined $subschema
1127 21474 2123 if (not length $fragment) { }
1136 757 2156 unless not length $our $_[1]{"path"}
1142 464 1659 if (@closest_resources > 1)
1156 21745 1852 unless length $canonical_uri->fragment
1166 2 578 unless my $subresource = ($$resource{"anchors"} // {})->{$fragment}
1181 52 1404 if substr($x, $pos, 1) ne substr($y, $pos, 1)
1211 1 3 unless $warn_add_media_type++
1228 2 22 unless $warn_get_media_type++
1269 0 4 if exists $$data{"max_traversal_depth"}