PackageURL/Util.pm

filter: Statementstmt 81.9% 177 / 216 Branchbran 53.7% 43 / 80 Conditioncond 34.1% 29 / 85 MC/DCmcdc 7.6% 4 / 52 Subroutinesub 91.6% 22 / 24 Podpod 100% 2 / 2 totaltotal 60.3% 277 / 459 CC 72 SCAR 24.9
CC
72
Cov
65%
_to_luarocks_urls
42.0
_to_npm_urls
29.0
_to_maven_urls
18.2
CRAP 12.0
« PackageURL.pm ↑ Summary VersionRange.pm »
1 package URI::PackageURL::Util;
2  
3 10 ▶use feature ':5.10';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 10 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use File::Basename qw(dirname basename);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 10 our $VERSION = '2.26';
14 10 our @EXPORT = qw(purl_to_urls purl_types);
15  
16 1 ▶sub purl_types {
Subroutine purl_types: called CC=5 SCAR=16.2
Pod documented
17  
18 1 my @list = ();
19  
20 1 my $spec_dir = File::Spec->catfile(dirname(__FILE__), 'types');
21  
22 1 ▶ opendir(my $dh, $spec_dir) or Carp::croak "Can't open spec dir: $!";
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $spec_dir or Carp::croak("Can't open spec dir: $!") 1 0 1
23  
24 1 ▶ while (my $file = readdir $dh) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $file = readdir $dh)) 44 1 45
25 44 ▶ next unless -f File::Spec->catfile($spec_dir, $file);
Branch: 1 branch
BranchTrueFalseTotal
unless -f "File::Spec"->catfile($spec_dir, $file) 2 42 44
26 42 $file =~ s/\-definition\.json//;
27 42 push @list, $file;
28 }
29  
30 1 closedir $dh;
31  
32 1 @list = sort @list;
33  
34 1 ▶ return wantarray ? @list : \@list;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 0 1
35  
36 }
37  
38 1872 ▶sub purl_to_urls {
Subroutine purl_to_urls: called CC=4 SCAR=14.1
Pod documented
39  
40 1872 my $purl = shift;
41  
42 1872 ▶ if (ref $purl ne 'URI::PackageURL') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $purl ne "URI::PackageURL") 17 1855 1872
43 17 require URI::PackageURL;
44 17 $purl = URI::PackageURL->from_string($purl);
45 }
46  
47 1872 my %TYPES = (
48 bitbucket => \&_to_bitbucket_urls,
49 cargo => \&_to_cargo_urls,
50 composer => \&_to_composer_urls,
51 cpan => \&_to_cpan_urls,
52 docker => \&_to_docker_urls,
53 gem => \&_to_gem_urls,
54 github => \&_to_github_urls,
55 gitlab => \&_to_gitlab_urls,
56 golang => \&_to_golang_urls,
57 luarocks => \&_to_luarocks_urls,
58 maven => \&_to_maven_urls,
59 npm => \&_to_npm_urls,
60 nuget => \&_to_nuget_urls,
61 pypi => \&_to_pypi_urls,
62 );
63  
64 1872 my $urls = {};
65  
66 1872 ▶ if (defined $TYPES{$purl->type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $TYPES{$purl->type}) 1872 0 1872
67 1872 $urls = $TYPES{$purl->type}->($purl);
68 }
69  
70 1872 ▶ if (my $download_url = $purl->qualifiers->{download_url}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $download_url = $purl->qualifiers->{"download_url"}) 0 1872 1872
71 0 $urls->{download} = $download_url;
72 }
73  
74 1872 return $urls;
75  
76 }
77  
78 1 ▶sub _to_bitbucket_urls {
Subroutine _to_bitbucket_urls: called CC=5 SCAR=16.7
79  
80 1 my $purl = shift;
81  
82 1 my $name = $purl->name;
83 1 my $namespace = $purl->namespace;
84 1 my $version = $purl->version;
85 1 my $qualifiers = $purl->qualifiers;
86 1 ▶ my $file_ext = $qualifiers->{ext} || 'tar.gz';
Condition50%1/2
$qualifiers->{'ext'} || 'tar.gz'
l!l
01
MC/DC0%0/1
$qualifiers->{'ext'} || 'tar.gz'
$qualifiers->{'ext'}
Truth table50%1/2
A
A= $qualifiers->{'ext'}
Aresult
11
00
87  
88 1 my $urls = {};
89  
90 1 ▶ if ($name && $namespace) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $namespace) 1 0 1
Condition33%1/3
$name and $namespace
!ll&&!rl&&r
001
MC/DC0%0/2
$name and $namespace
$name $namespace
Truth table33%1/3
A and B
A= $nameB= $namespace
ABresult
0X0
100
111
91 1 $urls->{repository} = "https://bitbucket.org/$namespace/$name";
92 }
93  
94 1 ▶ if ($version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version) 1 0 1
95 1 $urls->{download} = "https://bitbucket.org/$namespace/$name/get/$version.$file_ext";
96 }
97  
98 1 return $urls;
99  
100 }
101  
102 1 ▶sub _to_cargo_urls {
Subroutine _to_cargo_urls: called CC=3 SCAR=12.3
103  
104 1 my $purl = shift;
105  
106 1 my $name = $purl->name;
107 1 my $version = $purl->version;
108  
109 1 ▶ if ($name && $version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $version) 1 0 1
Condition33%1/3
$name and $version
!ll&&!rl&&r
001
MC/DC0%0/2
$name and $version
$name $version
Truth table33%1/3
A and B
A= $nameB= $version
ABresult
0X0
100
111
110 return {
111 1 repository => "https://crates.io/crates/$name/$version",
112 download => "https://crates.io/api/v1/crates/$name/$version/download"
113 };
114 }
115  
116 0 return {repository => "https://crates.io/crates/$name"};
117  
118 }
119  
120 1 ▶sub _to_composer_urls {
Subroutine _to_composer_urls: called CC=3 SCAR=11.8
121  
122 1 my $purl = shift;
123  
124 1 my $name = $purl->name;
125 1 my $namespace = $purl->namespace;
126  
127 1 ▶ return unless ($name && $namespace);
Branch: 1 branch
BranchTrueFalseTotal
unless $name and $namespace 0 1 1
Condition33%1/3
$name and $namespace
!ll&&!rl&&r
001
MC/DC0%0/2
$name and $namespace
$name $namespace
Truth table33%1/3
A and B
A= $nameB= $namespace
ABresult
0X0
100
111
128  
129 1 return {repository => "https://packagist.org/packages/$namespace/$name"};
130  
131 }
132  
133 1859 ▶sub _to_cpan_urls {
Subroutine _to_cpan_urls: called CC=14 SCAR=27.3
134  
135 1859 my ($purl, $purl_type) = @_;
136  
137 1859 my $name = $purl->name;
138 1859 my $version = $purl->version;
139 1859 my $qualifiers = $purl->qualifiers;
140 1859 ▶ my $author = $purl->namespace // $qualifiers->{author};
Condition100%3/3
$purl->namespace // $qualifiers->{"author"}
l!l&&r!l&&!r
5927927
MC/DC100%2/2
$purl->namespace // $qualifiers->{"author"}
$purl->namespace $qualifiers->{"author"}
Truth table100%3/3
A // B
A= $purl->namespaceB= $qualifiers->{"author"}
ABresult
1X1
011
000
141 1859 ▶ my $file_ext = $qualifiers->{ext} || 'tar.gz';
Condition50%1/2
$qualifiers->{'ext'} || 'tar.gz'
l!l
01859
MC/DC0%0/1
$qualifiers->{'ext'} || 'tar.gz'
$qualifiers->{'ext'}
Truth table50%1/2
A
A= $qualifiers->{'ext'}
Aresult
11
00
142 1859 ▶ my $repository_url = $qualifiers->{repository_url} || $purl->definition->default_repository_url;
Condition33%1/3
$qualifiers->{'repository_url'} || $purl->definition->default_repository_url
l!l&&r!l&&!r
018590
MC/DC0%0/2
$qualifiers->{'repository_url'} || $purl->definition->default_repository_url
$qualifiers->{'repository_url'} $purl->definition->default_repository_url
Truth table33%1/3
A || B
A= $qualifiers->{'repository_url'}B= $purl->definition->default_repository_url
ABresult
1X1
011
000
143 1859 my $distpath = $qualifiers->{distpath};
144 1859 my $distdir = $qualifiers->{distdir};
145  
146 1859 $repository_url =~ s{/$}{};
147  
148 1859 ▶ if ($repository_url !~ /^(http|https|file|ftp):\/\//) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($repository_url =~ m[^(http|https|file|ftp)://]) 0 1859 1859
149 0 $repository_url = 'https://' . $repository_url;
150 }
151  
152 1859 my $author_a = undef;
153 1859 my $author_au = undef;
154  
155 1859 ▶ if ($author) {
Branch: 1 branch
BranchTrueFalseTotal
if ($author) 932 927 1859
156 932 $author_a = substr($author, 0, 1);
157 932 $author_au = substr($author, 0, 2);
158 }
159  
160 1859 my $urls = {repository => "https://metacpan.org/dist/$name"};
161  
162 1859 ▶ if ($name && $version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $version) 1859 0 1859
Condition33%1/3
$name and $version
!ll&&!rl&&r
001859
MC/DC0%0/2
$name and $version
$name $version
Truth table33%1/3
A and B
A= $nameB= $version
ABresult
0X0
100
111
163  
164 1859 my $download_base_url = "$repository_url/authors/id";
165  
166 1859 ▶ if ($author) {
Branch: 1 branch
BranchTrueFalseTotal
if ($author) 932 927 1859
167 932 $urls->{download} = "$download_base_url/$author_a/$author_au/$author/$name-$version.$file_ext";
168 932 $urls->{repository} = "https://metacpan.org/release/$author/$name-$version";
169 }
170  
171 1859 ▶ if ($distpath && !$distdir) {
Branch: 1 branch
BranchTrueFalseTotal
if ($distpath and not $distdir) 1857 2 1859
Condition66%2/3
$distpath and not $distdir
!ll&&!rl&&r
201857
MC/DC50%1/2
$distpath and not $distdir
$distpath not $distdir
Truth table66%2/3
A and not(B)
A= $distpathB= not $distdir
ABresult
0X0
100
111
172  
173 1857 $distpath =~ s{^/}{};
174 1857 $distpath =~ s{^CPAN/}{};
175 1857 $distpath =~ s{^id/}{};
176 1857 $distpath =~ s{^authors/id/}{};
177  
178 1857 ▶ if ($distpath !~ /^([A-Z]{1})\/([A-Z]{2})/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($distpath =~ m[^([A-Z]{1})/([A-Z]{2})]) 928 929 1857
179  
180 928 my @parts = split '/', $distpath;
181  
182 928 $author_a = substr($parts[0], 0, 1);
183 928 $author_au = substr($parts[0], 0, 2);
184  
185 928 $distpath = join '/', $author_a, $author_au, $distpath;
186  
187 }
188  
189 1857 $urls->{download} = "$download_base_url/$distpath";
190  
191 }
192  
193 1859 ▶ if ($distdir && !$distpath) {
Branch: 1 branch
BranchTrueFalseTotal
if ($distdir and not $distpath) 0 1859 1859
Condition33%1/3
$distdir and not $distpath
!ll&&!rl&&r
185900
MC/DC0%0/2
$distdir and not $distpath
$distdir not $distpath
Truth table33%1/3
A and not(B)
A= $distdirB= not $distpath
ABresult
0X0
100
111
194 0 $urls->{download} = "$download_base_url/$author_a/$author_au/$author/$distdir/$name-$version.$file_ext";
195 }
196  
197 }
198  
199 1859 return $urls;
200  
201 }
202  
203 2 ▶sub _to_docker_urls {
Subroutine _to_docker_urls: called CC=7 SCAR=20.1
204  
205 2 my $purl = shift;
206  
207 2 my $name = $purl->name;
208 2 my $namespace = $purl->namespace;
209 2 my $version = $purl->version;
210 2 my $qualifiers = $purl->qualifiers;
211 2 ▶ my $repository_url = $qualifiers->{repository_url} || 'https://hub.docker.com';
Condition50%1/2
$qualifiers->{'repository_url'} || 'https://hub.docker.com'
l!l
02
MC/DC0%0/1
$qualifiers->{'repository_url'} || 'https://hub.docker.com'
$qualifiers->{'repository_url'}
Truth table50%1/2
A
A= $qualifiers->{'repository_url'}
Aresult
11
00
212  
213 2 ▶ if ($repository_url !~ /^(http|https):\/\//) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($repository_url =~ m[^(http|https)://]) 0 2 2
214 0 $repository_url = 'https://' . $repository_url;
215 }
216  
217 2 my $urls = {};
218  
219 2 ▶ if ($repository_url !~ /hub.docker.com/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($repository_url =~ /hub.docker.com/) 0 2 2
220 0 return $urls;
221 }
222  
223 2 ▶ if (!$namespace) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($namespace) 1 1 2
224 1 $urls->{repository} = "$repository_url/_/$name";
225 }
226  
227 2 ▶ if ($name && $namespace) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $namespace) 1 1 2
Condition66%2/3
$name and $namespace
!ll&&!rl&&r
011
MC/DC50%1/2
$name and $namespace
$name $namespace
Truth table66%2/3
A and B
A= $nameB= $namespace
ABresult
0X0
100
111
228 1 $urls->{repository} = "$repository_url/r/$namespace/$name";
229 }
230  
231 2 return $urls;
232  
233 }
234  
235 1 ▶sub _to_gem_urls {
Subroutine _to_gem_urls: called CC=3 SCAR=12.3
236  
237 1 my $purl = shift;
238  
239 1 my $name = $purl->name;
240 1 my $version = $purl->version;
241  
242 1 ▶ if ($name && $version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $version) 1 0 1
Condition33%1/3
$name and $version
!ll&&!rl&&r
001
MC/DC0%0/2
$name and $version
$name $version
Truth table33%1/3
A and B
A= $nameB= $version
ABresult
0X0
100
111
243 return {
244 1 repository => "https://rubygems.org/gems/$name/versions/$version",
245 download => "https://rubygems.org/downloads/$name-$version.gem"
246 };
247 }
248  
249 0 return {repository => "https://rubygems.org/gems/$name"};
250  
251 }
252  
253 2 ▶sub _to_github_urls {
Subroutine _to_github_urls: called CC=6 SCAR=18.3
254  
255 2 my $purl = shift;
256  
257 2 my $name = $purl->name;
258 2 my $namespace = $purl->namespace;
259 2 my $version = $purl->version;
260 2 my $qualifiers = $purl->qualifiers;
261 2 ▶ my $file_ext = $qualifiers->{ext} || 'tar.gz';
Condition50%1/2
$qualifiers->{'ext'} || 'tar.gz'
l!l
02
MC/DC0%0/1
$qualifiers->{'ext'} || 'tar.gz'
$qualifiers->{'ext'}
Truth table50%1/2
A
A= $qualifiers->{'ext'}
Aresult
11
00
262  
263 2 my $urls = {};
264  
265 2 ▶ if ($name && $namespace) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $namespace) 2 0 2
Condition33%1/3
$name and $namespace
!ll&&!rl&&r
002
MC/DC0%0/2
$name and $namespace
$name $namespace
Truth table33%1/3
A and B
A= $nameB= $namespace
ABresult
0X0
100
111
266 2 $urls->{repository} = "https://github.com/$namespace/$name";
267 }
268  
269 2 ▶ if ($version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version) 2 0 2
270  
271 2 my $is_sha1 = ($version =~ /^[a-fA-F0-9]{40}$/);
272  
273 2 ▶ if ($is_sha1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_sha1) { } 1 1 2
274 1 $urls->{download} = "https://github.com/$namespace/$name/archive/$version.$file_ext";
275 }
276 else {
277 1 $urls->{download} = "https://github.com/$namespace/$name/archive/refs/tags/$version.$file_ext";
278 }
279  
280 }
281  
282 2 return $urls;
283  
284 }
285  
286 1 ▶sub _to_gitlab_urls {
Subroutine _to_gitlab_urls: called CC=5 SCAR=16.7
287  
288 1 my $purl = shift;
289  
290 1 my $name = $purl->name;
291 1 my $namespace = $purl->namespace;
292 1 my $version = $purl->version;
293 1 my $qualifiers = $purl->qualifiers;
294 1 ▶ my $file_ext = $qualifiers->{ext} || 'tar.gz';
Condition50%1/2
$qualifiers->{'ext'} || 'tar.gz'
l!l
01
MC/DC0%0/1
$qualifiers->{'ext'} || 'tar.gz'
$qualifiers->{'ext'}
Truth table50%1/2
A
A= $qualifiers->{'ext'}
Aresult
11
00
295  
296 1 my $urls = {};
297  
298 1 ▶ if ($name && $namespace) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $namespace) 1 0 1
Condition33%1/3
$name and $namespace
!ll&&!rl&&r
001
MC/DC0%0/2
$name and $namespace
$name $namespace
Truth table33%1/3
A and B
A= $nameB= $namespace
ABresult
0X0
100
111
299 1 $urls->{repository} = "https://gitlab.com/$namespace/$name";
300 }
301  
302 1 ▶ if ($version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version) 1 0 1
303 1 $urls->{download} = "https://gitlab.com/$namespace/$name/-/archive/$version/$name-$version.$file_ext";
304 }
305  
306 1 return $urls;
307  
308 }
309  
310 0 ▶sub _to_golang_urls {
Subroutine _to_golang_urls: not called CC=3 SCAR=24.8
311  
312 0 my $purl = shift;
313  
314 0 my $name = $purl->name;
315 0 my $namespace = $purl->namespace;
316 0 my $version = $purl->version;
317  
318 0 my $urls = {};
319  
320 0 ▶ if ($name && $namespace) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $namespace) 0 0 0
Condition0%0/3
$name and $namespace
!ll&&!rl&&r
000
MC/DC0%0/2
$name and $namespace
$name $namespace
Truth table0%0/3
A and B
A= $nameB= $namespace
ABresult
0X0
100
111
321 0 $urls->{repository} = "https://pkg.go.dev/$namespace/$name";
322 }
323  
324 # TODO ???
325 # if ($name && $namespace && $version) {
326 # $urls->{repository} = "https://pkg.go.dev/$namespace/$name\@v$version";
327 # }
328  
329 0 return $urls;
330  
331 }
332  
333 0 ▶sub _to_luarocks_urls {
Subroutine _to_luarocks_urls: not called CC=6 SCAR=37.4
334  
335 0 my $purl = shift;
336  
337 0 my $name = $purl->name;
338 0 my $namespace = $purl->namespace;
339 0 my $version = $purl->version;
340 0 my $qualifiers = $purl->qualifiers;
341 0 ▶ my $repository_url = $qualifiers->{repository_url} || 'https://luarocks.org';
Condition0%0/2
$qualifiers->{'repository_url'} || 'https://luarocks.org'
l!l
00
MC/DC0%0/1
$qualifiers->{'repository_url'} || 'https://luarocks.org'
$qualifiers->{'repository_url'}
Truth table0%0/2
A
A= $qualifiers->{'repository_url'}
Aresult
11
00
342  
343 0 ▶ if ($repository_url !~ /^(http|https):\/\//) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($repository_url =~ m[^(http|https)://]) 0 0 0
344 0 $repository_url = 'https://' . $repository_url;
345 }
346  
347 0 my $urls = {};
348  
349 0 ▶ if (!$namespace) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($namespace) 0 0 0
350 0 $urls->{repository} = "$repository_url/modules/$name";
351 }
352  
353 0 ▶ if ($name && $namespace) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $namespace) 0 0 0
Condition0%0/3
$name and $namespace
!ll&&!rl&&r
000
MC/DC0%0/2
$name and $namespace
$name $namespace
Truth table0%0/3
A and B
A= $nameB= $namespace
ABresult
0X0
100
111
354 0 $urls->{repository} = "$repository_url/modules/$namespace/$name";
355 }
356  
357 0 return $urls;
358  
359 }
360  
361 1 ▶sub _to_maven_urls {
Subroutine _to_maven_urls: called CC=9 SCAR=29.0
362  
363 1 my $purl = shift;
364  
365 1 my $namespace = $purl->namespace;
366 1 my $name = $purl->name;
367 1 my $version = $purl->version;
368 1 my $qualifiers = $purl->qualifiers;
369 1 ▶ my $extension = $qualifiers->{extension} // 'jar';
Condition50%1/2
$qualifiers->{"extension"} // "jar"
l!l
01
MC/DC0%0/1
$qualifiers->{"extension"} // "jar"
$qualifiers->{"extension"}
Truth table50%1/2
A
A= $qualifiers->{"extension"}
Aresult
11
00
370 1 ▶ my $repository_url = $qualifiers->{repository_url} // 'https://repo.maven.apache.org/maven2';
Condition50%1/2
$qualifiers->{"repository_url"} // "https://repo.maven.apache.org/maven2"
l!l
01
MC/DC0%0/1
$qualifiers->{"repository_url"} // "https://repo.maven.apache.org/maven2"
$qualifiers->{"repository_url"}
Truth table50%1/2
A
A= $qualifiers->{"repository_url"}
Aresult
11
00
371  
372 1 ▶ if ($repository_url !~ /^(http|https):\/\//) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($repository_url =~ m[^(http|https)://]) 0 1 1
373 0 $repository_url = 'https://' . $repository_url;
374 }
375  
376 1 ▶ if ($namespace && $name && $version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($namespace and $name and $version) 1 0 1
Condition33%2/6
$namespace and $name and $version
!ll&&!rl&&r
001
$namespace and $name
!ll&&!rl&&r
001
MC/DC0%0/3
$namespace and $name and $version
$namespace $name $version
Truth table25%1/4
A and B and C
A= $namespaceB= $nameC= $version
ABCresult
0XX0
10X0
1100
1111
377  
378 1 (my $ns_url = $namespace) =~ s/\./\//g;
379  
380 return {
381 1 repository => "https://mvnrepository.com/artifact/$namespace/$name/$version",
382 download => "$repository_url/$ns_url/$name/$version/$name-$version.$extension"
383 };
384  
385 }
386  
387 0 ▶ if ($namespace && $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($namespace and $name) 0 0 0
Condition0%0/3
$namespace and $name
!ll&&!rl&&r
000
MC/DC0%0/2
$namespace and $name
$namespace $name
Truth table0%0/3
A and B
A= $namespaceB= $name
ABresult
0X0
100
111
388 0 return {repository => "https://mvnrepository.com/artifact/$namespace/$name"};
389 }
390  
391 }
392  
393 1 ▶sub _to_npm_urls {
Subroutine _to_npm_urls: called CC=8 SCAR=33.7
394  
395 1 my $purl = shift;
396  
397 1 my $namespace = $purl->namespace;
398 1 my $name = $purl->name;
399 1 my $version = $purl->version;
400  
401 1 ▶ if ($namespace && $name && $version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($namespace and $name and $version) 1 0 1
Condition33%2/6
$namespace and $name and $version
!ll&&!rl&&r
001
$namespace and $name
!ll&&!rl&&r
001
MC/DC0%0/3
$namespace and $name and $version
$namespace $name $version
Truth table25%1/4
A and B and C
A= $namespaceB= $nameC= $version
ABCresult
0XX0
10X0
1100
1111
402 return {
403 1 repository => "https://www.npmjs.com/package/$namespace/$name/v/$version",
404 download => "https://registry.npmjs.org/$namespace/$name/-/$name-$version.tgz"
405 };
406 }
407  
408 0 ▶ if ($name && $version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $version) 0 0 0
Condition0%0/3
$name and $version
!ll&&!rl&&r
000
MC/DC0%0/2
$name and $version
$name $version
Truth table0%0/3
A and B
A= $nameB= $version
ABresult
0X0
100
111
409 return {
410 0 repository => "https://www.npmjs.com/package/$name/v/$version",
411 download => "https://registry.npmjs.org/$name/-/$name-$version.tgz"
412 };
413 }
414  
415 0 ▶ if ($namespace && $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($namespace and $name) 0 0 0
Condition0%0/3
$namespace and $name
!ll&&!rl&&r
000
MC/DC0%0/2
$namespace and $name
$namespace $name
Truth table0%0/3
A and B
A= $namespaceB= $name
ABresult
0X0
100
111
416 0 return {repository => "https://www.npmjs.com/package/$namespace/$name"};
417 }
418  
419 0 return {repository => "https://www.npmjs.com/package/$name"};
420  
421 }
422  
423 1 ▶sub _to_nuget_urls {
Subroutine _to_nuget_urls: called CC=3 SCAR=12.3
424  
425 1 my $purl = shift;
426  
427 1 my $name = $purl->name;
428 1 my $version = $purl->version;
429  
430 1 ▶ if ($name && $version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $version) 1 0 1
Condition33%1/3
$name and $version
!ll&&!rl&&r
001
MC/DC0%0/2
$name and $version
$name $version
Truth table33%1/3
A and B
A= $nameB= $version
ABresult
0X0
100
111
431 return {
432 1 repository => "https://www.nuget.org/packages/$name/$version",
433 download => "https://www.nuget.org/api/v2/package/$name/$version"
434 };
435 }
436  
437 0 return {repository => "https://www.nuget.org/packages/$name"};
438  
439 }
440  
441 1 ▶sub _to_pypi_urls {
Subroutine _to_pypi_urls: called CC=3 SCAR=12.3
442  
443 1 my $purl = shift;
444  
445 1 my $name = $purl->name;
446 1 my $version = $purl->version;
447  
448 1 ▶ if ($name && $version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $version) 1 0 1
Condition33%1/3
$name and $version
!ll&&!rl&&r
001
MC/DC0%0/2
$name and $version
$name $version
Truth table33%1/3
A and B
A= $nameB= $version
ABresult
0X0
100
111
449 1 return {repository => "https://pypi.org/project/$name/$version"};
450 }
451  
452 0 return {repository => "https://pypi.org/project/$name"};
453  
454 }
455  
456 10 1;
457  
458 __END__
« PackageURL.pm ↑ Summary VersionRange.pm »