Branch Coverage

lib/Net/API/CPAN.pm
Criterion Covered Total %
branch 8 590 1.3


line true false branch
80 2 0 unless exists $self->{'api_version'}
81 2 0 unless exists $self->{'cache_file'}
82 2 0 unless exists $self->{'ua'}
85 0 2 unless $self->SUPER::init(@_)
86 2 0 unless (exists $self->{'ua'} and $self->_is_a($self->{'ua'}, "HTTP::Promise"))
92 0 2 unless $self->{'api_version'} =~ /^\d+$/
93 2 0 unless ($self->{'api_uri'})
104 0 0 if (exists $opts->{'author'} and length($opts->{'author'} // ""))
112 0 0 exists $opts->{'interval'} ? :
0 0 exists $opts->{'new'} ? :
116 0 0 if (exists $opts->{'distribution'} and length($opts->{'distribution'} // '')) { }
0 0 elsif (exists $opts->{'module'} and length($opts->{'module'} // '')) { }
0 0 elsif (exists $opts->{'new'}) { }
123 0 0 exists $opts->{'interval'} ? :
135 0 0 exists $opts->{'interval'} ? :
0 0 exists $opts->{'new'} ? :
146 0 0 exists $opts->{'interval'} ? :
164 0 0 if (@_) { }
166 0 0 if (scalar @_ == 1 and $self->_is_array($_[0])) { }
0 0 elsif (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
0 0 elsif (scalar @_ == 1 and !ref($_[0]) || ref $_[0] && overload::Method($_[0], '""')) { }
204 0 0 if (exists $opts->{'query'}) { }
0 0 elsif (exists $opts->{'prefix'}) { }
0 0 elsif (exists $opts->{'user'}) { }
212 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
225 0 0 $self->_is_array($opts->{'user'}) ? :
226 0 0 if (scalar @$users > 1) { }
0 0 elsif (scalar @$users) { }
267 0 0 if $self->_is_empty($term)
279 0 0 if (defined $ref and ref $ref eq 'HASH' and exists $ref->{'hits'} and ref $ref->{'hits'} eq 'HASH' and exists $ref->{'hits'}{'hits'} and ref $ref->{'hits'}{'hits'} eq 'ARRAY') { }
291 0 0 if (ref $this eq 'HASH' and exists $this->{'fields'} and ref $this->{'fields'} eq 'HASH') { }
300 0 0 if $self->_is_warnings_enabled
306 0 0 if $self->_is_warnings_enabled
319 0 0 if (exists $opts->{'distribution'}) { }
0 0 elsif (exists $opts->{'author'} and exists $opts->{'release'}) { }
0 0 elsif (exists $opts->{'release'} and defined $opts->{'release'}) { }
321 0 0 if $self->_is_empty($opts->{'distribution'})
329 0 0 if ($self->_is_array($opts->{'author'}) and $self->_is_array($opts->{'release'})) { }
332 0 0 if (scalar @{$opts->{'author'};} != scalar @{$opts->{'release'};})
350 0 0 if ($self->_is_empty($opts->{'author'})) { }
0 0 elsif ($self->_is_empty($opts->{'release'})) { }
370 0 0 if ($self->_is_array($opts->{'release'})) { }
418 0 0 if exists $self->{'_cached_clientinfo'} and defined $self->{'_cached_clientinfo'}
421 0 0 if ($resp->is_success)
431 0 0 if ($@)
433 0 0 if $self->_is_warnings_enabled
437 0 0 unless (scalar keys %$info)
453 0 0 if (defined $info->{$stage}{$prop} and length $info->{$stage}{$prop} and lc substr($info->{$stage}{$prop}, 0, 4) eq "http")
469 0 0 if (exists $opts->{'author'} and exists $opts->{'release'}) { }
0 0 elsif (exists $opts->{'author'}) { }
472 0 0 if ($self->_is_empty($opts->{'author'})) { }
0 0 elsif ($self->_is_empty($opts->{'release'})) { }
487 0 0 if ($self->_is_empty($opts->{'author'}))
509 0 0 if (exists $opts->{'release'}) { }
511 0 0 if ($self->_is_empty($opts->{'release'}))
530 0 0 exists $opts->{'accept'} ? :
531 0 0 if (exists $opts->{'file1'} and exists $opts->{'file2'}) { }
0 0 elsif (exists $opts->{'author1'} and exists $opts->{'release1'} and exists $opts->{'release2'}) { }
0 0 elsif (exists $opts->{'distribution'}) { }
534 0 0 if ($self->_is_empty($opts->{'file1'})) { }
0 0 elsif ($self->_is_empty($opts->{'file2'})) { }
544 0 0 $type eq 'text/plain' ? :
560 0 0 if $self->_is_empty($opts->{$t})
564 0 0 $type eq 'text/plain' ? :
575 0 0 if $self->_is_empty($opts->{'distribution'})
578 0 0 $type eq 'text/plain' ? :
596 0 0 if (@_) { }
599 0 0 if (scalar @_ == 1 and !ref($_[0]) || ref $_[0] && overload::Method($_[0], '""')) { }
0 0 elsif (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
627 0 0 if (exists $opts->{'query'}) { }
635 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
665 0 0 $opts->{'dev'} ? :
0 0 $opts->{'version'} ? :
673 0 0 if (@_) { }
676 0 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
695 0 0 if (exists $opts->{'query'}) { }
0 0 elsif (exists $opts->{'aggregate'} or exists $opts->{'agg'}) { }
0 0 elsif (exists $opts->{'distribution'}) { }
0 0 elsif (exists $opts->{'user'}) { }
0 0 elsif (exists $opts->{'leaderboard'}) { }
0 0 elsif (exists $opts->{'recent'}) { }
703 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
712 0 0 if $self->_is_empty($agg)
719 0 0 if (ref $ref eq "HASH" and exists $ref->{'favorites'} and ref $ref->{'favorites'} eq "HASH")
733 0 0 if $self->_is_empty($opts->{'distribution'})
740 0 0 if (ref $ref eq "HASH" and exists $ref->{'users'} and ref $ref->{'users'} eq "ARRAY")
752 0 0 if $self->_is_empty($opts->{'user'})
767 0 0 if (ref $ref eq "HASH" and exists $ref->{'leaderboard'} and ref $ref->{'leaderboard'} eq "ARRAY")
807 0 0 unless $type =~ /^\w+$/
813 0 0 if (exists $opts->{'request'}) { }
815 0 0 unless ($self->_is_a($opts->{'request'}, "HTTP::Promise::Request"))
829 0 0 substr($ep, 0, 1) eq '/' ? :
833 0 0 if ($self->_is_code($opts->{'postprocess'}))
838 0 0 if (exists $opts->{'headers'})
840 0 0 unless $self->_is_array($opts->{'headers'})
843 0 0 if (exists $opts->{'payload'})
846 0 0 if (ref $payload eq "HASH")
854 0 0 if ($@)
859 0 0 if (exists $opts->{'method'} and lc $opts->{'method'} ne "post" and lc $opts->{'method'} ne "put")
866 0 0 if (exists $opts->{'query'})
873 0 0 if (my $cache_file = $self->cache_file) { }
0 0 elsif (defined $req) { }
0 0 elsif (lc $meth eq 'get') { }
0 0 elsif (lc $meth eq 'post') { }
891 0 0 if (defined $headers)
900 0 0 if (defined $query)
902 0 0 if (ref $query eq 'HASH' or $self->_is_array($query)) { }
0 0 elsif (not ref $query or ref $query and overload::Method($query, '""')) { }
910 0 0 if ($@)
921 0 0 if (defined $payload)
923 0 0 unless $req->content($payload)
925 0 0 unless ($req->headers->exists("Content-Type"))
943 0 0 if (defined $payload and defined $headers and not scalar grep(/^Content[_-]Type$/i, @$headers))
961 0 0 if ($self->_is_a($resp, "HTTP::Promise::Exception"))
969 0 0 if ($resp->is_success or $resp->is_redirect) { }
974 0 0 if ($resp->headers->content_is_json) { }
984 0 0 if ($@)
999 0 0 if (defined $postprocess)
1007 0 0 if ($@)
1014 0 0 if (ref $class eq 'CODE') { }
1023 0 0 length $result > 255 ? :
1024 0 0 if ($@) { }
0 0 elsif (not defined $result) { }
1039 0 0 unless $self->_load_class($class)
1056 0 0 exists $opts->{'list_preprocess'} && ref $opts->{'list_preprocess'} eq 'CODE' ? :
0 0 exists $opts->{'list_postprocess'} && ref $opts->{'list_postprocess'} eq 'CODE' ? :
0 0 $class->isa('Net::API::CPAN::List') ? :
0 0 exists $opts->{'args'} && ref $opts->{'args'} eq 'HASH' ? :
1059 0 0 unless ($class->isa("Net::API::CPAN::List"))
1062 0 0 unless $result->apply($data)
1070 0 0 if ($resp->header('Content-Type') =~ m[text/html]) { }
0 0 elsif ($resp->headers->type =~ /json/i) { }
1087 0 0 if ($@)
1097 0 0 if (exists $data->{'error'} and defined $data->{'error'}) { }
1100 0 0 if (ref $data->{'error'} eq 'HASH' and exists $data->{'error'}{'message'}) { }
0 0 elsif (not ref $data->{'error'}) { }
1106 0 0 exists $data->{'error'}{'code'} ? :
1134 0 0 if (@_) { }
1137 0 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
1156 0 0 if (exists $opts->{'query'}) { }
0 0 elsif (exists $opts->{'author'} and exists $opts->{'release'} and exists $opts->{'dir'}) { }
0 0 elsif (exists $opts->{'author'} and exists $opts->{'release'} and exists $opts->{'path'}) { }
1164 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1174 0 0 if ($self->_is_empty($opts->{$t}))
1187 0 0 if (ref $ref eq "HASH" and exists $ref->{'dir'} and ref $ref->{'dir'} eq "ARRAY")
1194 0 0 if (defined $this and ref $this eq "HASH")
1198 0 0 if (scalar @keys)
1221 0 0 if ($self->_is_empty($opts->{$t}))
1250 0 0 if $self->_is_empty($term)
1260 0 0 if (exists $ref->{'abstract.analyzed'})
1279 0 0 unless ($type =~ /^(?:module|file|documentation)$/)
1283 0 0 if ($type eq 'module' and exists $opts->{'module'}) { }
0 0 elsif ($type eq 'file' and exists $opts->{'distribution'}) { }
0 0 elsif ($type eq 'documentation' and exists $opts->{'module'}) { }
1313 0 0 if $self->{'json'}
1330 0 0 if (@_) { }
1333 0 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
1352 0 0 if (exists $opts->{'query'}) { }
0 0 elsif (exists $opts->{'module'} and length($opts->{'module'} // '')) { }
1360 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1369 0 0 if (exists $opts->{'join'})
1374 0 0 length($opts->{'join'} // '') ? :
0 0 $self->_is_array($opts->{'join'}) ? :
1384 0 0 unless defined $join
1385 0 0 if not defined $ref or ref $ref ne "HASH"
1388 0 0 if (exists $ref->{$t} and ref $ref->{$t} eq "HASH" and exists $ref->{$t}{'_source'} and ref $ref->{$t}{'_source'} eq "HASH")
1398 0 0 $join ? :
1419 0 0 unless $self->_load_class("Net::API::CPAN::Filter")
1428 0 0 if (@_) { }
1437 0 0 if (ref $ref eq "HASH" and exists $ref->{'hits'} and ref $ref->{'hits'} eq "HASH" and exists $ref->{'hits'}{'hits'} and ref $ref->{'hits'}{'hits'} eq "ARRAY")
1446 0 0 if (defined $this and ref $this eq "HASH" and exists $this->{'_source'} and ref $this->{'_source'} eq "HASH" and exists $this->{'_source'}{'version'} and defined $this->{'_source'}{'version'} and $this->{'_source'}{'version'} eq "undef")
1461 0 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
0 0 elsif (scalar @_ == 1 and !ref($_[0]) || ref $_[0] && overload::Method($_[0], '""')) { }
1490 0 0 if (exists $opts->{'query'}) { }
0 0 elsif (exists $opts->{'distribution'}) { }
1498 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1505 0 0 if $self->_is_empty($opts->{'distribution'})
1511 0 0 if (ref $ref ne 'HASH' or ref $ref eq 'HASH' and not exists $ref->{'modules'}) { }
0 0 elsif (ref $ref->{'modules'} ne 'ARRAY') { }
1542 0 0 if (@_) { }
1545 0 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
1564 0 0 if (exists $opts->{'query'}) { }
0 0 elsif (exists $opts->{'author'}) { }
0 0 elsif (exists $opts->{'module'}) { }
1572 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1578 0 0 if $self->_is_empty($opts->{'author'})
1584 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1595 0 0 if ($self->_is_array($opts->{'module'})) { }
1607 0 0 if $self->_is_empty($opts->{'module'})
1633 0 0 unless (scalar keys %$opts)
1637 0 0 if (exists $opts->{'author'} and exists $opts->{'release'} and exists $opts->{'path'}) { }
0 0 elsif (exists $opts->{'module'}) { }
0 0 elsif (exists $opts->{'render'}) { }
1643 0 0 if ($self->_is_empty($opts->{$t}))
1658 0 0 exists $opts->{'accept'} ? :
0 0 exists $opts->{'accept'} ? :
1664 0 0 if ($self->_is_empty($opts->{'module'})) { }
0 0 elsif (not $self->_is_module($opts->{'module'})) { }
1681 0 0 exists $opts->{'accept'} ? :
0 0 exists $opts->{'accept'} ? :
1687 0 0 if ($self->_is_empty($opts->{'render'}))
1708 0 0 if (@_) { }
1711 0 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
1730 0 0 if (exists $opts->{'query'}) { }
0 0 elsif (exists $opts->{'distribution'}) { }
0 0 elsif (exists $opts->{'distribution'}) { }
1738 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1744 0 0 if $self->_is_empty($opts->{'author'})
1751 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1757 0 0 $self->_is_array($opts->{'distribution'}) ? :
1784 0 0 if (@_) { }
1787 0 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
1807 0 0 if (exists $opts->{'query'}) { }
0 0 elsif (exists $opts->{'all'}) { }
0 0 elsif (exists $opts->{'author'} and exists $opts->{'release'} and exists $opts->{'contributors'}) { }
0 0 elsif (exists $opts->{'author'} and exists $opts->{'release'} and exists $opts->{'files'}) { }
0 0 elsif (exists $opts->{'author'} and exists $opts->{'release'} and exists $opts->{'modules'}) { }
0 0 elsif (exists $opts->{'author'} and exists $opts->{'release'} and exists $opts->{'interesting_files'} || exists $opts->{'interesting'}) { }
0 0 elsif (exists $opts->{'author'} and exists $opts->{'release'}) { }
0 0 elsif (exists $opts->{'author'} and exists $opts->{'latest'}) { }
0 0 elsif (exists $opts->{'distribution'} and exists $opts->{'latest'}) { }
0 0 elsif (exists $opts->{'distribution'} and exists $opts->{'versions'}) { }
0 0 elsif (exists $opts->{'author'}) { }
0 0 elsif (exists $opts->{'distribution'}) { }
0 0 elsif (exists $opts->{'recent'}) { }
1815 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1822 0 0 if $self->_is_empty($opts->{'all'})
1834 0 0 exists $opts->{'page'} ? :
0 0 exists $opts->{'size'} ? :
1843 0 0 if $self->_is_empty($opts->{'author'})
1844 0 0 if $self->_is_empty($opts->{'release'})
1856 0 0 if $self->_is_empty($opts->{'author'})
1857 0 0 if $self->_is_empty($opts->{'release'})
1869 0 0 if $self->_is_empty($opts->{'author'})
1870 0 0 if $self->_is_empty($opts->{'release'})
1882 0 0 if $self->_is_empty($opts->{'author'})
1883 0 0 if $self->_is_empty($opts->{'release'})
1894 0 0 if $self->_is_empty($opts->{'author'})
1895 0 0 if $self->_is_empty($opts->{'release'})
1903 0 0 if (exists $ref->{'release'} and defined $ref->{'release'} and ref $ref->{'release'} eq "HASH")
1917 0 0 if $self->_is_empty($opts->{'author'})
1928 0 0 if $self->_is_empty($opts->{'distribution'})
1935 0 0 if (exists $ref->{'release'} and defined $ref->{'release'} and ref $ref->{'release'} eq "HASH")
1951 0 0 if (exists $opts->{'plain'} and not $self->_is_empty($opts->{'plain'}))
1957 0 0 if ($self->_is_array($opts->{'versions'}) and scalar @{$opts->{'versions'};} or defined $opts->{'versions'} and length "$opts->{'versions'}")
1960 0 0 if ($self->_is_array($opts->{'versions'})) { }
1978 0 0 defined $query ? :
0 0 $opts->{'plain'} ? :
1984 0 0 if $self->_is_empty($opts->{'author'})
1997 0 0 if (defined $ref and ref $ref eq "HASH" and exists $ref->{'releases'} and defined $ref->{'releases'} and ref $ref->{'releases'} eq "ARRAY")
2006 0 0 if (exists $this->{'metadata'})
2014 0 0 exists $opts->{'page'} ? :
0 0 exists $opts->{'size'} ? :
2019 0 0 if $self->_is_empty($opts->{'distribution'})
2035 0 0 exists $opts->{'page'} ? :
0 0 exists $opts->{'size'} ? :
2058 0 0 if (exists $opts->{'distribution'} and length($opts->{'distribution'} // '')) { }
0 0 elsif (exists $opts->{'module'} and length($opts->{'module'} // '')) { }
2067 0 0 exists $opts->{'page'} ? :
0 0 exists $opts->{'size'} ? :
0 0 exists $opts->{'sort'} ? :
2080 0 0 exists $opts->{'page'} ? :
0 0 exists $opts->{'size'} ? :
0 0 exists $opts->{'sort'} ? :
2101 0 0 unless $type =~ /^[a-zA-Z]\w+$/
2114 0 0 exists $opts->{'accept'} ? :
2123 0 0 if (exists $opts->{'author'} and length($opts->{'author'} // '') and exists $opts->{'release'} and length($opts->{'release'} // '') and exists $opts->{'path'} and length($opts->{'path'} // '')) { }
0 0 elsif (exists $opts->{'module'} and length($opts->{'module'} // '')) { }
2157 0 0 if $self->_is_empty($opts->{'query'})
2173 0 0 if (exists $opts->{'range'} and not $self->_is_empty($opts->{'range'}) and $opts->{'range'} =~ /^\w+$/)
2179 0 0 if (exists $opts->{'size'} and not $self->_is_empty($opts->{'size'}) and $opts->{'size'} =~ /^\d+$/)
2194 0 0 if (exists $ref->{'counts'} and defined $ref->{'counts'} and ref $ref->{'counts'} eq "HASH")
2202 0 0 defined $query ? :
2211 0 0 if $self->_is_empty($opts->{'query'})
2221 0 0 $opts->{'collapsed'} ? :
0 0 length $opts->{'from'} ? :
0 0 length $opts->{'size'} ? :
2234 1 0 if (exists $Net::API::CPAN::TYPE2CLASS->{$type}) { }
0 0 elsif ($type =~ /^$Net::API::CPAN::MODULE_RE$/) { }
2252 0 0 unless (exists $opts->{'fields'} and length($opts->{'fields'} // ""))
2258 0 0 if ($self->_is_array($fields)) { }
0 0 elsif (not ref $fields or ref $fields and $self->_is_scalar($fields) and $self->_can_overload($fields, '""')) { }
2262 0 0 if (not ref $_ or ref $_ and $self->_is_scalar($_) and $self->_can_overload($_, "\"\""))
2272 0 0 if $clean->is_empty