API/Source.pm

filter: Statementstmt 100% 29 / 29 Branchbran 87.5% 7 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 90.5% 48 / 53 CC 7 SCAR 15.1
CC
7
Cov
93%
source
7.1
BEGIN
1.0
BEGIN
1.0
CRAP 4.5
« API/Autocomplete.pm ↑ Summary API/Distribution.pm »
1 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package MetaCPAN::API::Source;
4  
5 17 our $VERSION = '0.52';
6  
7 17 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 17 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 17 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # /source/{author}/{release}/{path}
12 3 ▶sub source {
Subroutine source: called CC=7 SCAR=19.6
Pod documented
13 3 my $self = shift;
14 3 ▶ my %opts = @_ ? @_ : ();
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 1 3
15 3 my $url = '';
16 3 my $error = "Provide 'author' and 'release' and 'path'";
17  
18 3 ▶ %opts or croak $error;
Branch: 1 branch
BranchTrueFalseTotal
%opts or croak($error) 2 1 3
19  
20 2 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $author = $opts{'author'}) and defined(my $release = $opts{'release'}) and defined(my $path = $opts{'path'})) { } 1 1 2
Condition66%4/6
defined(my $author = $opts{"author"}) and defined(my $release = $opts{"release"}) and defined(my $path = $opts{"path"})
!ll&&!rl&&r
101
defined(my $author = $opts{"author"}) and defined(my $release = $opts{"release"})
!ll&&!rl&&r
101
MC/DC33%1/3
defined(my $author = $opts{"author"}) and defined(my $release = $opts{"release"}) and defined(my $path = $opts{"path"})
defined(my $author = $opts{"author"}) defined(my $release = $opts{"release"}) defined(my $path = $opts{"path"})
Truth table50%2/4
A and B and C
A= defined(my $author = $opts{"author"})B= defined(my $release = $opts{"release"})C= defined(my $path = $opts{"path"})
ABCresult
0XX0
10X0
1100
1111
21 defined ( my $author = $opts{'author'} ) &&
22 defined ( my $release = $opts{'release'} ) &&
23 defined ( my $path = $opts{'path'} )
24 ) {
25 1 $url = "source/$author/$release/$path";
26 } else {
27 1 croak $error;
28 }
29  
30 1 $url = $self->base_url . "/$url";
31  
32 1 my $result = $self->ua->get($url);
33 1 ▶ $result->{'success'}
Branch: 1 branch
BranchTrueFalseTotal
$result->{"success"} or croak(qq[Failed to fetch '${url}': $result->{"reason"} - $result->{"content"}]) 1 0 1
34 or croak "Failed to fetch '$url': $result->{'reason'} - $result->{'content'}";
35  
36 1 return $result->{'content'};
37 }
38  
39 17 1;
40  
41 __END__
« API/Autocomplete.pm ↑ Summary API/Distribution.pm »