Branch Coverage

blib/lib/JSON/Schema/Modern.pm
Criterion Covered Total %
branch 263 320 82.1


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 17392 if @_ < 2
153 1 17391 if ($_[0]->$JSON::Schema::Modern::_isa("JSON::Schema::Modern::Document"))
159 0 17358 $_[0]->$JSON::Schema::Modern::_isa('Mojo::URL') ? :
33 17358 !is_schema($_[0]) ? :
162 1 17390 if defined $uri->fragment
163 0 17390 unless @_
165 1 17389 if ($_[0]->$JSON::Schema::Modern::_isa("JSON::Schema::Modern::Document"))
181 12302 5087 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 766245 if $existing_checksum eq $schema_checksum
195 0 18201 if @_ < 2
199 0 10 $_[0]->$JSON::Schema::Modern::_isa('Mojo::URL') ? :
18191 10 !$_[0]->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Document') ? :
202 0 18201 if defined $base_uri->fragment
203 0 18201 unless @_
206 0 18201 unless $document->$JSON::Schema::Modern::_isa("JSON::Schema::Modern::Document")
209 180 18021 if $document->has_errors
216 17188 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 17941 if keys %overrides
304 0 17941 unless $initial_path =~ m[^(?:/|\z)]u
306 4 17937 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 17872 $$config_override{'skip_ref_checks'} ? :
338 5932 12009 ref $schema_reference eq 'HASH' && exists $$schema_reference{'$schema'} ? :
340 17935 6 if (my $metaschema_info = $self->_get_metaschema_vocabulary_classes($$state{'metaschema_uri'})) { }
347 0 6 unless $$config_override{"metaschema_uri"}
354 17937 4 if $valid and not @{$$state{"errors"}}
355 0 165 unless $valid or @{$$state{"errors"}}
356 0 17941 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 17387 unless defined wantarray
380 0 17387 if keys %overrides
394 17313 74 if (is_schema($schema_reference)) { }
4 133 elsif (ref $schema_reference and not $schema_reference->$JSON::Schema::Modern::_isa('Mojo::URL')) { }
403 6 17192 unless $schema_info
407 1 17191 unless $$schema_info{"document"}->get_entity_at_location($$schema_info{"document_path"})
420 68437 51900 defined $val ? :
423 9 17182 $$config_override{'with_defaults'} // $self->with_defaults ? :
427 5 17186 if $$config_override{"_strict_schema_data"}
436 0 7524 unless $valid or @{$$state{"errors"}}
437 0 17168 if $valid and @{$$state{"errors"}}
440 180 39 if ($e->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Result')) { }
34 5 elsif ($e->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Error')) { }
451 5 17202 if ($$state{"seen_data_properties"})
462 7 1 @{$unknown_keywords{$parent}} > 1 ? :
466 0 17207 if $valid xor not @{$$state{"errors"}}
476 28 9612 $$config_override{'collect_annotations'} // $self->collect_annotations ? :
9640 7567 $valid ? :
9 17198 $$state{'defaults'} ? :
481 0 10 unless defined wantarray
484 6 4 ref $schema eq 'HASH' && $$schema{'$schema'} ? :
487 5 5 $self->strict || $$config_override{'strict'} ? :
489 7 3 unless $result->valid
497 1 2 if @{$$state{"errors"}}
503 5 3 if (wantarray) { }
505 1 4 unless $schema_info
506 3 1 ref $$schema_info{'schema'} ? :
510 3 0 unless ref $uri_reference
513 0 3 unless $resource
516 2 1 if (not length $fragment or $fragment =~ m[^/]u) { }
520 1 0 unless my $subresource = ($$resource{"anchors"} // {})->{$fragment}
523 1 1 ref $schema ? :
529 0 0 unless $schema_info
583 0 42162 if $$state{"depth"}++ > $self->max_traversal_depth
590 7711 8 if $schema_type eq "boolean" and $$state{'specification_version'} ne 'draft4' || $$state{'keyword_path'} =~ m[/(?:additional(?:Items|Properties)|uniqueItems)\z]u
592 17 34434 if $schema_type ne "object"
594 1198 33236 unless keys %$schema
618 1627429 56837 unless exists $$schema{$keyword}
621 36 53488 if $keyword ne "\$ref" and exists $$schema{"\$ref"} and $$state{"specification_version"} =~ /^draft[467]\z/u
629 243 56558 unless (&$sub($vocabulary, $schema, $state))
631 0 243 if $error_count == @{$$state{"errors"}}
636 0 56558 if $error_count != @{$$state{"errors"}}
639 68 56490 if $$state{"specification_version"} ne $old_spec_version
641 4 56554 if (my $callback = $$state{"callbacks"}{$keyword})
644 0 4 unless (&$callback($schema, $state))
646 0 0 if $error_count == @{$$state{"errors"}}
651 0 4 if $error_count != @{$$state{"errors"}}
658 2 81 if ($self->strict and keys %unknown_keywords)
659 2 0 keys %unknown_keywords > 1 ? :
665 103766 224 unless exists $$schema{$keyword}
668 224 0 if (my $alternates = $removed_keywords{$$state{"specification_version"}}{$keyword})
670 0 224 if @list > 2
671 167 57 if @list > 1
681 0 34827 unless defined wantarray
689 3 34824 if $$state{"depth"}++ > $self->max_traversal_depth
692 844 33980 if $schema_type eq "boolean"
695 0 33980 if $schema_type ne "object"
697 637 33343 unless keys %$schema
707 1 33342 if grep((substr($schema_location, 0, length $_) eq $_), keys %{$$state{"seen"}{$$state{"data_path"}}{$canonical_uri}})
729 48 33294 if $$state{"defaults"}
751 1449798 60016 unless exists $$schema{$keyword}
754 31 56345 if $keyword ne "\$ref" and exists $$schema{"\$ref"} and $$state{"specification_version"} =~ /^draft[467]\z/u
757 1 1839 if not $valid and $$state{"short_circuit"} and $$state{"strict"}
761 55908 4076 if ($sub)
766 13161 42703 unless (&$sub($vocabulary, $data, $schema, $state))
768 0 13161 if $error_count == @{$$state{"errors"}}
771 6213 6948 if $$state{"short_circuit"} and not $$state{"strict"}
776 0 42703 if $error_count != @{$$state{"errors"}}
779 42 2 if $e->$JSON::Schema::Modern::_isa("JSON::Schema::Modern::Error")
784 3 42700 if $$state{"specification_version"} ne $old_spec_version
787 19 46760 if (my $callback = ($$state{"callbacks"} // {})->{$keyword})
790 2 17 unless (&$callback($data, $schema, $state))
792 0 2 if $error_count == @{$$state{"errors"}}
795 1 1 if $$state{"short_circuit"} and not $$state{"strict"}
799 0 17 if $error_count != @{$$state{"errors"}}
806 3 197 if ($$state{"strict"} and keys %unknown_keywords)
807 1 2 keys %unknown_keywords > 1 ? :
813 156 33139 if ($$state{"seen_data_properties"} and $is_object_data)
821 287 290 grep(($keyword eq $_), ('properties', 'additionalProperties', 'patternProperties', 'unevaluatedProperties')) ? :
829 2 154 if exists $$data{"\$ref"} and $$state{"specification_version"} eq "draft4"
832 969 19331 if ($valid and $$state{"collect_annotations"} and not $$state{"specification_version"} =~ /^draft(?:[467]|2019-09)\z/u)
838 20300 12995 if $valid
842 37 33258 if $valid and $$state{"defaults"}
866 0 44029 if $_[1] =~ /#/u
884 17055 1919 if (my $existing = $self->_get_resource($canonical_uri)) { }
2 1917 elsif (JSON::Schema::Modern::Utilities::get_schema_filename($canonical_uri)) { }
887 859 16196 if ($canonical_uri ne "")
892 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'}) ? :
893 849 10 unless @diffs
930 0 10 if grep(($our $_[1] eq $classname), values %{$self->__vocabulary_classes})
940 1 3 if grep /^\$/u, $classname->keywords
979 2 51 unless (exists $$schema_info{"schema"}{"\$vocabulary"})
989 1 50 if length $$schema_info{"document_path"}
990 1 50 unless exists $$schema_info{"schema"}{"\$id"}
992 2 49 unless $valid
999 8 97 if $$schema_info{"schema"}{"\$vocabulary"}{$uri} and not $class_info
1001 8 89 unless $class_info
1006 6 83 if $spec_version ne $$schema_info{"specification_version"}
1012 0 1 $a->evaluation_order == 999 ? :
0 48 unless $a->evaluation_order <=> $b->evaluation_order
1017 9 40 if ($vocabulary_classes[0] // "") ne "JSON::Schema::Modern::Vocabulary::Core"
1025 1 793 if $seen_keyword{$keyword}
1030 32 17 $valid ? :
1083 24310 114 if $resource
1085 103 11 if (my $document = load_cached_document($self, $uri))
1104 24186 0 unless is_schema($uri_reference)
1108 11 24175 unless $resource
1111 23595 580 if (not length $fragment or $fragment =~ m[^/]u) { }
1113 2 23593 unless defined $subschema
1116 21472 2121 if (not length $fragment) { }
1125 757 2152 unless not length $our $_[1]{"path"}
1131 462 1659 if (@closest_resources > 1)
1145 21743 1850 unless length $canonical_uri->fragment
1155 2 578 unless my $subresource = ($$resource{"anchors"} // {})->{$fragment}
1170 48 1358 if substr($x, $pos, 1) ne substr($y, $pos, 1)
1181 0 0 eval { do { 'JSON::PP'->VERSION('4.11'); 1 } } ? :
45 0 eval { do { 'Cpanel::JSON::XS'->VERSION('4.38'); 1 } } ? :
1234 29 9 if $mt
1236 14 35 if m[([^/]+)/\*\z]u