Branch Coverage

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


line true false branch
124 0 11 if exists(($$self{"_format_validations"} // {})->{$format})
126 6 5 if ref $definition ne "HASH"
131 1 3 if CORE::any {$format eq $_;} @core_formats and $$definition{"type"} ne "string"
155 0 17380 if @_ < 2
158 1 17379 if ($_[0]->$JSON::Schema::Modern::_isa("JSON::Schema::Modern::Document"))
164 0 17346 $_[0]->$JSON::Schema::Modern::_isa('Mojo::URL') ? :
33 17346 !is_schema($_[0]) ? :
167 1 17378 if defined $uri->fragment
168 0 17378 unless @_
170 1 17377 if ($_[0]->$JSON::Schema::Modern::_isa("JSON::Schema::Modern::Document"))
186 12292 5085 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))))
189 12292 709944 if $existing_checksum eq $schema_checksum
200 0 18189 if @_ < 2
204 0 10 $_[0]->$JSON::Schema::Modern::_isa('Mojo::URL') ? :
18179 10 !$_[0]->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Document') ? :
207 0 18189 if defined $base_uri->fragment
208 0 18189 unless @_
211 0 18189 unless $document->$JSON::Schema::Modern::_isa("JSON::Schema::Modern::Document")
214 180 18009 if $document->has_errors
221 17176 833 unless (length $base_uri)
250 73 96 $our $_[1] ? :
256 826 30 if $$new_resource{"path"} eq "" and not $uri_string =~ /#./u
260 64 762 if $root[0] ne $base_uri
266 0 3 unless defined wantarray
300 0 17929 if keys %overrides
309 0 17929 unless $initial_path =~ m[^(?:/|\z)]u
311 4 17925 if (length(my $uri_path = $initial_uri->fragment))
312 0 4 unless $uri_path =~ m[^/]u
314 0 4 if substr($initial_path, -length($uri_path)) ne $uri_path
330 69 17860 $$config_override{'skip_ref_checks'} ? :
343 5932 11997 ref $schema_reference eq 'HASH' && exists $$schema_reference{'$schema'} ? :
345 17923 6 if (my $metaschema_info = $self->_get_metaschema_vocabulary_classes($$state{'metaschema_uri'})) { }
352 0 6 unless $$config_override{"metaschema_uri"}
359 17925 4 if $valid and not @{$$state{"errors"}}
360 0 165 unless $valid or @{$$state{"errors"}}
361 0 17929 if $valid and @{$$state{"errors"}}
364 0 0 if ($e->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Result')) { }
0 0 elsif ($e->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Error')) { }
381 0 17375 unless defined wantarray
385 0 17375 if keys %overrides
399 17301 74 if (is_schema($schema_reference)) { }
4 133 elsif (ref $schema_reference and not $schema_reference->$JSON::Schema::Modern::_isa('Mojo::URL')) { }
408 6 17180 unless $schema_info
412 1 17179 unless $$schema_info{"document"}->get_entity_at_location($$schema_info{"document_path"})
425 68389 51864 defined $val ? :
428 9 17170 $$config_override{'with_defaults'} // $self->with_defaults ? :
432 5 17174 if $$config_override{"_strict_schema_data"}
441 0 7506 unless $valid or @{$$state{"errors"}}
442 0 17156 if $valid and @{$$state{"errors"}}
445 180 39 if ($e->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Result')) { }
34 5 elsif ($e->$JSON::Schema::Modern::_isa('JSON::Schema::Modern::Error')) { }
456 5 17190 if ($$state{"seen_data_properties"})
467 7 1 @{$unknown_keywords{$parent}} > 1 ? :
471 0 17195 if $valid xor not @{$$state{"errors"}}
481 28 9618 $$config_override{'collect_annotations'} // $self->collect_annotations ? :
9646 7549 $valid ? :
9 17186 $$state{'defaults'} ? :
486 0 10 unless defined wantarray
489 6 4 ref $schema eq 'HASH' && $$schema{'$schema'} ? :
492 5 5 $self->strict || $$config_override{'strict'} ? :
494 7 3 unless $result->valid
502 1 2 if @{$$state{"errors"}}
508 5 3 if (wantarray) { }
510 1 4 unless $schema_info
511 3 1 ref $$schema_info{'schema'} ? :
515 3 0 unless ref $uri_reference
518 0 3 unless $resource
521 2 1 if (not length $fragment or $fragment =~ m[^/]u) { }
525 1 0 unless my $subresource = ($$resource{"anchors"} // {})->{$fragment}
528 1 1 ref $schema ? :
534 0 0 unless $schema_info
588 0 42150 if $$state{"depth"}++ > $self->max_traversal_depth
595 7711 8 if $schema_type eq "boolean" and $$state{'specification_version'} ne 'draft4' || $$state{'keyword_path'} =~ m[/(?:additional(?:Items|Properties)|uniqueItems)\z]u
597 17 34422 if $schema_type ne "object"
599 1198 33224 unless keys %$schema
623 1626757 56825 unless exists $$schema{$keyword}
626 36 53476 if $keyword ne "\$ref" and exists $$schema{"\$ref"} and $$state{"specification_version"} =~ /^draft[467]\z/u
634 243 56546 unless (&$sub($vocabulary, $schema, $state))
636 0 243 if $error_count == @{$$state{"errors"}}
641 0 56546 if $error_count != @{$$state{"errors"}}
644 68 56478 if $$state{"specification_version"} ne $old_spec_version
646 4 56542 if (my $callback = $$state{"callbacks"}{$keyword})
649 0 4 unless (&$callback($schema, $state))
651 0 0 if $error_count == @{$$state{"errors"}}
656 0 4 if $error_count != @{$$state{"errors"}}
663 2 81 if ($self->strict and keys %unknown_keywords)
664 2 0 keys %unknown_keywords > 1 ? :
670 103700 224 unless exists $$schema{$keyword}
673 224 0 if (my $alternates = $removed_keywords{$$state{"specification_version"}}{$keyword})
675 0 224 if @list > 2
676 167 57 if @list > 1
686 0 34815 unless defined wantarray
694 3 34812 if $$state{"depth"}++ > $self->max_traversal_depth
697 844 33968 if $schema_type eq "boolean"
700 0 33968 if $schema_type ne "object"
702 637 33331 unless keys %$schema
712 1 33330 if grep((substr($schema_location, 0, length $_) eq $_), keys %{$$state{"seen"}{$$state{"data_path"}}{$canonical_uri}})
734 48 33282 if $$state{"defaults"}
756 1449369 60004 unless exists $$schema{$keyword}
759 31 56333 if $keyword ne "\$ref" and exists $$schema{"\$ref"} and $$state{"specification_version"} =~ /^draft[467]\z/u
762 1 1839 if not $valid and $$state{"short_circuit"} and $$state{"strict"}
766 55896 4076 if ($sub)
771 13143 42709 unless (&$sub($vocabulary, $data, $schema, $state))
773 0 13143 if $error_count == @{$$state{"errors"}}
776 6204 6939 if $$state{"short_circuit"} and not $$state{"strict"}
781 0 42709 if $error_count != @{$$state{"errors"}}
784 42 2 if $e->$JSON::Schema::Modern::_isa("JSON::Schema::Modern::Error")
789 3 42706 if $$state{"specification_version"} ne $old_spec_version
792 19 46766 if (my $callback = ($$state{"callbacks"} // {})->{$keyword})
795 2 17 unless (&$callback($data, $schema, $state))
797 0 2 if $error_count == @{$$state{"errors"}}
800 1 1 if $$state{"short_circuit"} and not $$state{"strict"}
804 0 17 if $error_count != @{$$state{"errors"}}
811 3 197 if ($$state{"strict"} and keys %unknown_keywords)
812 1 2 keys %unknown_keywords > 1 ? :
818 156 33127 if ($$state{"seen_data_properties"} and $is_object_data)
826 287 290 grep(($keyword eq $_), ('properties', 'additionalProperties', 'patternProperties', 'unevaluatedProperties')) ? :
834 2 154 if exists $$data{"\$ref"} and $$state{"specification_version"} eq "draft4"
837 969 19337 if ($valid and $$state{"collect_annotations"} and not $$state{"specification_version"} =~ /^draft(?:[467]|2019-09)\z/u)
843 20306 12977 if $valid
847 37 33246 if $valid and $$state{"defaults"}
871 0 44006 if $_[1] =~ /#/u
889 17042 1921 if (my $existing = $self->_get_resource($canonical_uri)) { }
2 1919 elsif (JSON::Schema::Modern::Utilities::get_schema_filename($canonical_uri)) { }
892 859 16183 if ($canonical_uri ne "")
897 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'}) ? :
898 849 10 unless @diffs
935 0 10 if grep(($our $_[1] eq $classname), values %{$self->__vocabulary_classes})
945 1 3 if grep /^\$/u, $classname->keywords
984 2 51 unless (exists $$schema_info{"schema"}{"\$vocabulary"})
994 1 50 if length $$schema_info{"document_path"}
995 1 50 unless exists $$schema_info{"schema"}{"\$id"}
997 2 49 unless $valid
1004 8 97 if $$schema_info{"schema"}{"\$vocabulary"}{$uri} and not $class_info
1006 8 89 unless $class_info
1011 6 83 if $spec_version ne $$schema_info{"specification_version"}
1017 0 1 $a->evaluation_order == 999 ? :
0 48 unless $a->evaluation_order <=> $b->evaluation_order
1022 9 40 if ($vocabulary_classes[0] // "") ne "JSON::Schema::Modern::Vocabulary::Core"
1030 1 793 if $seen_keyword{$keyword}
1035 32 17 $valid ? :
1088 24298 114 if $resource
1090 103 11 if (my $document = load_cached_document($self, $uri))
1109 24174 0 unless is_schema($uri_reference)
1113 11 24163 unless $resource
1116 23583 580 if (not length $fragment or $fragment =~ m[^/]u) { }
1118 2 23581 unless defined $subschema
1121 21460 2121 if (not length $fragment) { }
1130 757 2152 unless not length $our $_[1]{"path"}
1136 462 1659 if (@closest_resources > 1)
1150 21731 1850 unless length $canonical_uri->fragment
1160 2 578 unless my $subresource = ($$resource{"anchors"} // {})->{$fragment}
1175 48 1358 if substr($x, $pos, 1) ne substr($y, $pos, 1)
1186 0 0 eval { do { 'JSON::PP'->VERSION('4.11'); 1 } } ? :
45 0 eval { do { 'Cpanel::JSON::XS'->VERSION('4.38'); 1 } } ? :
1239 29 9 if $mt
1241 12 29 if m[([^/]+)/\*\z]u