Branch Coverage

lib/Net/API/CPAN.pm
Criterion Covered Total %
branch 8 586 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")
804 0 0 unless $type =~ /^\w+$/
810 0 0 if (exists $opts->{'request'}) { }
812 0 0 unless ($self->_is_a($opts->{'request'}, "HTTP::Promise::Request"))
826 0 0 substr($ep, 0, 1) eq '/' ? :
830 0 0 if ($self->_is_code($opts->{'postprocess'}))
835 0 0 if (exists $opts->{'headers'})
837 0 0 unless $self->_is_array($opts->{'headers'})
840 0 0 if (exists $opts->{'payload'})
843 0 0 if (ref $payload eq "HASH")
851 0 0 if ($@)
856 0 0 if (exists $opts->{'method'} and lc $opts->{'method'} ne "post" and lc $opts->{'method'} ne "put")
863 0 0 if (exists $opts->{'query'})
870 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') { }
888 0 0 if (defined $headers)
897 0 0 if (defined $query)
899 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, '""')) { }
907 0 0 if ($@)
918 0 0 if (defined $payload)
920 0 0 unless $req->content($payload)
922 0 0 unless ($req->headers->exists("Content-Type"))
940 0 0 if (defined $payload and defined $headers and not scalar grep(/^Content[_-]Type$/i, @$headers))
958 0 0 if ($self->_is_a($resp, "HTTP::Promise::Exception"))
966 0 0 if ($resp->is_success or $resp->is_redirect) { }
971 0 0 if ($resp->headers->content_is_json) { }
981 0 0 if ($@)
996 0 0 if (defined $postprocess)
1004 0 0 if ($@)
1011 0 0 if (ref $class eq 'CODE') { }
1020 0 0 length $result > 255 ? :
1021 0 0 if ($@) { }
0 0 elsif (not defined $result) { }
1036 0 0 unless $self->_load_class($class)
1053 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' ? :
1056 0 0 unless ($class->isa("Net::API::CPAN::List"))
1059 0 0 unless $result->apply($data)
1067 0 0 if ($resp->header('Content-Type') =~ m[text/html]) { }
0 0 elsif ($resp->headers->type =~ /json/i) { }
1084 0 0 if ($@)
1094 0 0 if (exists $data->{'error'} and defined $data->{'error'}) { }
1097 0 0 if (ref $data->{'error'} eq 'HASH' and exists $data->{'error'}{'message'}) { }
0 0 elsif (not ref $data->{'error'}) { }
1103 0 0 exists $data->{'error'}{'code'} ? :
1131 0 0 if (@_) { }
1134 0 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
1153 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'}) { }
1161 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1171 0 0 if ($self->_is_empty($opts->{$t}))
1184 0 0 if (ref $ref eq "HASH" and exists $ref->{'dir'} and ref $ref->{'dir'} eq "ARRAY")
1191 0 0 if (defined $this and ref $this eq "HASH")
1195 0 0 if (scalar @keys)
1218 0 0 if ($self->_is_empty($opts->{$t}))
1247 0 0 if $self->_is_empty($term)
1257 0 0 if (exists $ref->{'abstract.analyzed'})
1276 0 0 unless ($type =~ /^(?:module|file|documentation)$/)
1280 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'}) { }
1310 0 0 if $self->{'json'}
1327 0 0 if (@_) { }
1330 0 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
1349 0 0 if (exists $opts->{'query'}) { }
0 0 elsif (exists $opts->{'module'} and length($opts->{'module'} // '')) { }
1357 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1366 0 0 if (exists $opts->{'join'})
1371 0 0 length($opts->{'join'} // '') ? :
0 0 $self->_is_array($opts->{'join'}) ? :
1381 0 0 unless defined $join
1382 0 0 if not defined $ref or ref $ref ne "HASH"
1385 0 0 if (exists $ref->{$t} and ref $ref->{$t} eq "HASH" and exists $ref->{$t}{'_source'} and ref $ref->{$t}{'_source'} eq "HASH")
1395 0 0 $join ? :
1416 0 0 unless $self->_load_class("Net::API::CPAN::Filter")
1425 0 0 if (@_) { }
1428 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], '""')) { }
1456 0 0 if (exists $opts->{'query'}) { }
0 0 elsif (exists $opts->{'distribution'}) { }
1472 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")
1481 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")
1496 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1500 0 0 if $self->_is_empty($opts->{'distribution'})
1506 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') { }
1537 0 0 if (@_) { }
1540 0 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
1559 0 0 if (exists $opts->{'query'}) { }
0 0 elsif (exists $opts->{'author'}) { }
0 0 elsif (exists $opts->{'module'}) { }
1567 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1573 0 0 if $self->_is_empty($opts->{'author'})
1579 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1590 0 0 if ($self->_is_array($opts->{'module'})) { }
1602 0 0 if $self->_is_empty($opts->{'module'})
1628 0 0 unless (scalar keys %$opts)
1632 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'}) { }
1638 0 0 if ($self->_is_empty($opts->{$t}))
1653 0 0 exists $opts->{'accept'} ? :
0 0 exists $opts->{'accept'} ? :
1659 0 0 if ($self->_is_empty($opts->{'module'})) { }
0 0 elsif (not $self->_is_module($opts->{'module'})) { }
1676 0 0 exists $opts->{'accept'} ? :
0 0 exists $opts->{'accept'} ? :
1682 0 0 if ($self->_is_empty($opts->{'render'}))
1703 0 0 if (@_) { }
1706 0 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
1725 0 0 if (exists $opts->{'query'}) { }
0 0 elsif (exists $opts->{'distribution'}) { }
0 0 elsif (exists $opts->{'distribution'}) { }
1733 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1739 0 0 if $self->_is_empty($opts->{'author'})
1746 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1752 0 0 $self->_is_array($opts->{'distribution'}) ? :
1779 0 0 if (@_) { }
1782 0 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Net::API::CPAN::Filter')) { }
1802 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'}) { }
1810 0 0 exists $opts->{'from'} ? :
0 0 exists $opts->{'size'} ? :
1817 0 0 if $self->_is_empty($opts->{'all'})
1829 0 0 exists $opts->{'page'} ? :
0 0 exists $opts->{'size'} ? :
1838 0 0 if $self->_is_empty($opts->{'author'})
1839 0 0 if $self->_is_empty($opts->{'release'})
1851 0 0 if $self->_is_empty($opts->{'author'})
1852 0 0 if $self->_is_empty($opts->{'release'})
1864 0 0 if $self->_is_empty($opts->{'author'})
1865 0 0 if $self->_is_empty($opts->{'release'})
1877 0 0 if $self->_is_empty($opts->{'author'})
1878 0 0 if $self->_is_empty($opts->{'release'})
1889 0 0 if $self->_is_empty($opts->{'author'})
1890 0 0 if $self->_is_empty($opts->{'release'})
1898 0 0 if (exists $ref->{'release'} and defined $ref->{'release'} and ref $ref->{'release'} eq "HASH")
1912 0 0 if $self->_is_empty($opts->{'author'})
1923 0 0 if $self->_is_empty($opts->{'distribution'})
1930 0 0 if (exists $ref->{'release'} and defined $ref->{'release'} and ref $ref->{'release'} eq "HASH")
1946 0 0 if (exists $opts->{'plain'} and not $self->_is_empty($opts->{'plain'}))
1952 0 0 if ($self->_is_array($opts->{'versions'}) and scalar @{$opts->{'versions'};} or defined $opts->{'versions'} and length "$opts->{'versions'}")
1955 0 0 if ($self->_is_array($opts->{'versions'})) { }
1973 0 0 defined $query ? :
0 0 $opts->{'plain'} ? :
1979 0 0 if $self->_is_empty($opts->{'author'})
1987 0 0 exists $opts->{'page'} ? :
0 0 exists $opts->{'size'} ? :
1994 0 0 if $self->_is_empty($opts->{'distribution'})
2010 0 0 exists $opts->{'page'} ? :
0 0 exists $opts->{'size'} ? :
2033 0 0 if (exists $opts->{'distribution'} and length($opts->{'distribution'} // '')) { }
0 0 elsif (exists $opts->{'module'} and length($opts->{'module'} // '')) { }
2042 0 0 exists $opts->{'page'} ? :
0 0 exists $opts->{'size'} ? :
0 0 exists $opts->{'sort'} ? :
2055 0 0 exists $opts->{'page'} ? :
0 0 exists $opts->{'size'} ? :
0 0 exists $opts->{'sort'} ? :
2076 0 0 unless $type =~ /^[a-zA-Z]\w+$/
2089 0 0 exists $opts->{'accept'} ? :
2098 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'} // '')) { }
2132 0 0 if $self->_is_empty($opts->{'query'})
2148 0 0 if (exists $opts->{'range'} and not $self->_is_empty($opts->{'range'}) and $opts->{'range'} =~ /^\w+$/)
2154 0 0 if (exists $opts->{'size'} and not $self->_is_empty($opts->{'size'}) and $opts->{'size'} =~ /^\d+$/)
2169 0 0 if (exists $ref->{'counts'} and defined $ref->{'counts'} and ref $ref->{'counts'} eq "HASH")
2177 0 0 defined $query ? :
2186 0 0 if $self->_is_empty($opts->{'query'})
2196 0 0 $opts->{'collapsed'} ? :
0 0 length $opts->{'from'} ? :
0 0 length $opts->{'size'} ? :
2209 1 0 if (exists $Net::API::CPAN::TYPE2CLASS->{$type}) { }
0 0 elsif ($type =~ /^$Net::API::CPAN::MODULE_RE$/) { }
2227 0 0 unless (exists $opts->{'fields'} and length($opts->{'fields'} // ""))
2233 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, '""')) { }
2237 0 0 if (not ref $_ or ref $_ and $self->_is_scalar($_) and $self->_can_overload($_, "\"\""))
2247 0 0 if $clean->is_empty