Branch Coverage

blib/lib/JSON/Schema/Modern.pm
Criterion Covered Total %
branch 265 322 82.3


line true false branch
119 0 11 if exists(($$self{"_format_validations"} // {})->{$format})
121 6 5 if ref $definition ne "HASH"
126 1 3 if core_formats_type()->check($format) and $$definition{"type"} ne "string"
150 0 17394 if @_ < 2
153 1 17393 if ($_[0]->$JSON::Schema::Modern::_isa("JSON::Schema::Modern::Document"))
159 0 17360 $_[0]->$JSON::Schema::Modern::_isa('Mojo::URL') ? :
33 17360 !is_schema($_[0]) ? :
162 1 17392 if defined $uri->fragment
163 0 17392 unless @_
165 1 17391 if ($_[0]->$JSON::Schema::Modern::_isa("JSON::Schema::Modern::Document"))
181 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))))
184 12302 672368 if $existing_checksum eq $schema_checksum
195 0 18203 if @_ < 2
199 0 10 $_[0]->$JSON::Schema::Modern::_isa('Mojo::URL') ? :
18193 10 !$_[0]->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Document') ? :
202 0 18203 if defined $base_uri->fragment
203 0 18203 unless @_
206 0 18203 unless $document->$JSON::Schema::Modern::_isa("JSON::Schema::Modern::Document")
209 180 18023 if $document->has_errors
216 17190 833 unless (length $base_uri)
245 73 96 $our $_[1] ? :
251 826 30 if $$new_resource{"path"} eq "" and not $uri_string =~ /#./u
255 64 762 if $root[0] ne $base_uri
261 0 3 unless defined wantarray
295 0 17943 if keys %overrides
304 0 17943 unless $initial_path =~ m[^(?:/|\z)]u
306 4 17939 if (length(my $uri_path = $initial_uri->fragment))
307 0 4 unless $uri_path =~ m[^/]u
309 0 4 if substr($initial_path, -length($uri_path)) ne $uri_path
325 69 17874 $$config_override{'skip_ref_checks'} ? :
338 5932 12011 ref $schema_reference eq 'HASH' && exists $$schema_reference{'$schema'} ? :
340 17937 6 if (my $metaschema_info = $self->_get_metaschema_vocabulary_classes($$state{'metaschema_uri'})) { }
347 0 6 unless $$config_override{"metaschema_uri"}
354 17939 4 if $valid and not @{$$state{"errors"}}
355 0 165 unless $valid or @{$$state{"errors"}}
356 0 17943 if $valid and @{$$state{"errors"}}
359 0 0 if ($e->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Result')) { }
0 0 elsif ($e->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Error')) { }
376 0 17390 unless defined wantarray
380 0 17390 if keys %overrides
392 10765 6625 ref $data ? :
396 17315 75 if (is_schema($schema_reference)) { }
4 135 elsif (ref $schema_reference and not $schema_reference->$JSON::Schema::Modern::_isa('Mojo::URL')) { }
405 6 17195 unless $schema_info
409 1 17194 unless $$schema_info{"document"}->get_entity_at_location($$schema_info{"document_path"})
422 68446 51912 defined $val ? :
425 10 17184 $$config_override{'with_defaults'} // $self->with_defaults ? :
429 5 17189 if $$config_override{"_strict_schema_data"}
438 0 7524 unless $valid or @{$$state{"errors"}}
439 0 17171 if $valid and @{$$state{"errors"}}
442 180 39 if ($e->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Result')) { }
34 5 elsif ($e->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Error')) { }
453 5 17205 if ($$state{"seen_data_properties"})
464 7 1 @{$unknown_keywords{$parent}} > 1 ? :
468 0 17210 if $valid xor not @{$$state{"errors"}}
480 28 9615 $$config_override{'collect_annotations'} // $self->collect_annotations ? :
9643 7567 $valid ? :
10 17200 $$state{'defaults'} ? :
484 0 10 unless defined wantarray
487 6 4 ref $schema eq 'HASH' && $$schema{'$schema'} ? :
490 5 5 $self->strict || $$config_override{'strict'} ? :
492 7 3 unless $result->valid
500 1 2 if @{$$state{"errors"}}
506 5 3 if (wantarray) { }
508 1 4 unless $schema_info
509 3 1 ref $$schema_info{'schema'} ? :
513 3 0 unless ref $uri_reference
516 0 3 unless $resource
519 2 1 if (not length $fragment or $fragment =~ m[^/]u) { }
523 1 0 unless my $subresource = ($$resource{"anchors"} // {})->{$fragment}
526 1 1 ref $schema ? :
532 0 0 unless $schema_info
586 0 42172 if $$state{"depth"}++ > $self->max_traversal_depth
593 7710 8 if $schema_type eq "boolean" and $$state{'specification_version'} ne 'draft4' || $$state{'keyword_path'} =~ m[/(?:additional(?:Items|Properties)|uniqueItems)\z]u
595 17 34445 if $schema_type ne "object"
597 1199 33246 unless keys %$schema
621 1627964 56872 unless exists $$schema{$keyword}
624 36 53523 if $keyword ne "\$ref" and exists $$schema{"\$ref"} and $$state{"specification_version"} =~ /^draft[467]\z/u
632 243 56593 unless (&$sub($vocabulary, $schema, $state))
634 0 243 if $error_count == @{$$state{"errors"}}
639 0 56593 if $error_count != @{$$state{"errors"}}
642 68 56525 if $$state{"specification_version"} ne $old_spec_version
644 4 56589 if (my $callback = $$state{"callbacks"}{$keyword})
647 0 4 unless (&$callback($schema, $state))
649 0 0 if $error_count == @{$$state{"errors"}}
654 0 4 if $error_count != @{$$state{"errors"}}
661 2 81 if ($self->strict and keys %unknown_keywords)
662 2 0 keys %unknown_keywords > 1 ? :
668 103826 224 unless exists $$schema{$keyword}
671 224 0 if (my $alternates = $removed_keywords{$$state{"specification_version"}}{$keyword})
673 0 224 if @list > 2
674 167 57 if @list > 1
684 0 34834 unless defined wantarray
692 3 34831 if $$state{"depth"}++ > $self->max_traversal_depth
695 844 33987 if $schema_type eq "boolean"
698 0 33987 if $schema_type ne "object"
700 638 33349 unless keys %$schema
710 1 33348 if grep((substr($schema_location, 0, length $_) eq $_), keys %{$$state{"seen"}{$$state{"data_path"}}{$canonical_uri}})
732 52 33296 if $$state{"defaults"}
754 1450119 60037 unless exists $$schema{$keyword}
757 31 56365 if $keyword ne "\$ref" and exists $$schema{"\$ref"} and $$state{"specification_version"} =~ /^draft[467]\z/u
760 1 1840 if not $valid and $$state{"short_circuit"} and $$state{"strict"}
764 55929 4076 if ($sub)
769 13161 42724 unless (&$sub($vocabulary, $data, $schema, $state))
771 0 13161 if $error_count == @{$$state{"errors"}}
774 6213 6948 if $$state{"short_circuit"} and not $$state{"strict"}
779 0 42724 if $error_count != @{$$state{"errors"}}
782 42 2 if $e->$JSON::Schema::Modern::_isa("JSON::Schema::Modern::Error")
787 3 42721 if $$state{"specification_version"} ne $old_spec_version
790 24 46776 if (my $callback = ($$state{"callbacks"} // {})->{$keyword})
793 2 22 unless (&$callback($data, $schema, $state))
795 0 2 if $error_count == @{$$state{"errors"}}
798 1 1 if $$state{"short_circuit"} and not $$state{"strict"}
802 0 22 if $error_count != @{$$state{"errors"}}
809 3 197 if ($$state{"strict"} and keys %unknown_keywords)
810 1 2 keys %unknown_keywords > 1 ? :
816 156 33145 if ($$state{"seen_data_properties"} and $is_object_data)
824 287 290 grep(($keyword eq $_), ('properties', 'additionalProperties', 'patternProperties', 'unevaluatedProperties')) ? :
832 2 154 if exists $$data{"\$ref"} and $$state{"specification_version"} eq "draft4"
835 969 19337 if ($valid and $$state{"collect_annotations"} and not $$state{"specification_version"} =~ /^draft(?:[467]|2019-09)\z/u)
841 20306 12995 if $valid
845 41 33260 if $valid and $$state{"defaults"}
869 0 44035 if $_[1] =~ /#/u
887 17055 1921 if (my $existing = $self->_get_resource($canonical_uri)) { }
2 1919 elsif (JSON::Schema::Modern::Utilities::get_schema_filename($canonical_uri)) { }
890 859 16196 if ($canonical_uri ne "")
895 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'}) ? :
896 849 10 unless @diffs
933 0 10 if grep(($our $_[1] eq $classname), values %{$self->__vocabulary_classes})
943 1 3 if grep /^\$/u, $classname->keywords
982 2 51 unless (exists $$schema_info{"schema"}{"\$vocabulary"})
992 1 50 if length $$schema_info{"document_path"}
993 1 50 unless exists $$schema_info{"schema"}{"\$id"}
995 2 49 unless $valid
1002 8 97 if $$schema_info{"schema"}{"\$vocabulary"}{$uri} and not $class_info
1004 8 89 unless $class_info
1009 6 83 if $spec_version ne $$schema_info{"specification_version"}
1015 0 1 $a->evaluation_order == 999 ? :
0 48 unless $a->evaluation_order <=> $b->evaluation_order
1020 9 40 if ($vocabulary_classes[0] // "") ne "JSON::Schema::Modern::Vocabulary::Core"
1028 1 793 if $seen_keyword{$keyword}
1033 32 17 $valid ? :
1086 24314 114 if $resource
1088 103 11 if (my $document = load_cached_document($self, $uri))
1107 24190 0 unless is_schema($uri_reference)
1111 11 24179 unless $resource
1114 23599 580 if (not length $fragment or $fragment =~ m[^/]u) { }
1116 2 23597 unless defined $subschema
1119 21474 2123 if (not length $fragment) { }
1128 757 2156 unless not length $our $_[1]{"path"}
1134 464 1659 if (@closest_resources > 1)
1148 21745 1852 unless length $canonical_uri->fragment
1158 2 578 unless my $subresource = ($$resource{"anchors"} // {})->{$fragment}
1173 52 1404 if substr($x, $pos, 1) ne substr($y, $pos, 1)
1184 0 0 eval { do { 'JSON::PP'->VERSION('4.11'); 1 } } ? :
45 0 eval { do { 'Cpanel::JSON::XS'->VERSION('4.38'); 1 } } ? :
1237 30 9 if $mt
1239 13 39 if m[([^/]+)/\*\z]u