PackageURL/Util.pm

filter: Statementstmt 77.0% 164 / 213 Branchbran 44.8% 35 / 78 Conditioncond 32.9% 30 / 91 MC/DCmcdc 5.4% 3 / 55 Subroutinesub 87.5% 21 / 24 Podpod 100% 2 / 2 totaltotal 55.0% 255 / 463 CC 73 SCAR 26.3
CC
73
Cov
60%
_to_luarocks_urls
42.0
purl_types
30.0
_to_npm_urls
29.0
CRAP 13.9
« PackageURL/Type.pm ↑ Summary VersionRange/Util.pm »
1 package URI::PackageURL::Util;
2  
3 9 ▶use feature ':5.10';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use File::Basename qw(dirname basename);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 9 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 9 our $VERSION = '2.25';
14 9 our @EXPORT = qw(purl_to_urls purl_types);
15  
16 0 ▶sub purl_types {
Subroutine purl_types: not called CC=5 SCAR=34.0
Pod documented
17  
18 0 my @list = ();
19  
20 0 my $spec_dir = File::Spec->catfile(dirname(__FILE__), 'types');
21  
22 0 ▶ 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: $!") 0 0 0
23  
24 0 ▶ while (my $file = readdir $dh) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $file = readdir $dh)) 0 0 0
25 0 ▶ next unless -f File::Spec->catfile($spec_dir, $file);
Branch: 1 branch
BranchTrueFalseTotal
unless -f "File::Spec"->catfile($spec_dir, $file) 0 0 0
26 0 $file =~ s/\-definition\.json//;
27 0 push @list, $file;
28 }
29  
30 0 closedir $dh;
31  
32 0 @list = sort @list;
33  
34 0 ▶ return wantarray ? @list : \@list;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
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=15 SCAR=29.4
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};
Condition33%1/3
$purl->namespace // $qualifiers->{"author"}
l!l&&r!l&&!r
185900
MC/DC0%0/2
$purl->namespace // $qualifiers->{"author"}
$purl->namespace $qualifiers->{"author"}
Truth table33%1/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 $urls = {repository => "https://metacpan.org/dist/$name"};
153  
154 1859 ▶ if ($name && $version && $author) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $version and $author) 1859 0 1859
Condition33%2/6
$name and $version and $author
!ll&&!rl&&r
001859
$name and $version
!ll&&!rl&&r
001859
MC/DC0%0/3
$name and $version and $author
$name $version $author
Truth table25%1/4
A and B and C
A= $nameB= $versionC= $author
ABCresult
0XX0
10X0
1100
1111
155  
156 1859 $urls->{repository} = "https://metacpan.org/release/$author/$name-$version";
157  
158 1859 my $author_a = substr($author, 0, 1);
159 1859 my $author_au = substr($author, 0, 2);
160  
161 1859 my $download_base_url = "$repository_url/authors/id";
162  
163 1859 ▶ if (!$distpath && !$distdir) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($distpath or $distdir) 2 1857 1859
Condition66%2/3
$distpath or $distdir
l!l&&r!l&&!r
185702
MC/DC50%1/2
$distpath or $distdir
$distpath $distdir
Truth table66%2/3
A or B
A= $distpathB= $distdir
ABresult
1X1
011
000
164 2 $urls->{download} = "$download_base_url/$author_a/$author_au/$author/$name-$version.$file_ext";
165 }
166  
167 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
168  
169 1857 $distpath =~ s{^/}{};
170 1857 $distpath =~ s{^CPAN/}{};
171 1857 $distpath =~ s{^id/}{};
172 1857 $distpath =~ s{^authors/id/}{};
173  
174 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
175  
176 928 my @parts = split '/', $distpath;
177 928 my $author_a = substr($parts[0], 0, 1);
178 928 my $author_au = substr($parts[0], 0, 2);
179  
180 928 $distpath = join '/', $author_a, $author_au, $distpath;
181  
182 }
183  
184 1857 $urls->{download} = "$download_base_url/$distpath";
185  
186 }
187  
188 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
189 0 $urls->{download} = "$download_base_url/$author_a/$author_au/$author/$distdir/$name-$version.$file_ext";
190 }
191  
192 }
193  
194 1859 return $urls;
195  
196 }
197  
198 2 ▶sub _to_docker_urls {
Subroutine _to_docker_urls: called CC=7 SCAR=20.1
199  
200 2 my $purl = shift;
201  
202 2 my $name = $purl->name;
203 2 my $namespace = $purl->namespace;
204 2 my $version = $purl->version;
205 2 my $qualifiers = $purl->qualifiers;
206 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
207  
208 2 ▶ if ($repository_url !~ /^(http|https):\/\//) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($repository_url =~ m[^(http|https)://]) 0 2 2
209 0 $repository_url = 'https://' . $repository_url;
210 }
211  
212 2 my $urls = {};
213  
214 2 ▶ if ($repository_url !~ /hub.docker.com/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($repository_url =~ /hub.docker.com/) 0 2 2
215 0 return $urls;
216 }
217  
218 2 ▶ if (!$namespace) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($namespace) 1 1 2
219 1 $urls->{repository} = "$repository_url/_/$name";
220 }
221  
222 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
223 1 $urls->{repository} = "$repository_url/r/$namespace/$name";
224 }
225  
226 2 return $urls;
227  
228 }
229  
230 1 ▶sub _to_gem_urls {
Subroutine _to_gem_urls: called CC=3 SCAR=12.3
231  
232 1 my $purl = shift;
233  
234 1 my $name = $purl->name;
235 1 my $version = $purl->version;
236  
237 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
238 return {
239 1 repository => "https://rubygems.org/gems/$name/versions/$version",
240 download => "https://rubygems.org/downloads/$name-$version.gem"
241 };
242 }
243  
244 0 return {repository => "https://rubygems.org/gems/$name"};
245  
246 }
247  
248 2 ▶sub _to_github_urls {
Subroutine _to_github_urls: called CC=6 SCAR=18.3
249  
250 2 my $purl = shift;
251  
252 2 my $name = $purl->name;
253 2 my $namespace = $purl->namespace;
254 2 my $version = $purl->version;
255 2 my $qualifiers = $purl->qualifiers;
256 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
257  
258 2 my $urls = {};
259  
260 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
261 2 $urls->{repository} = "https://github.com/$namespace/$name";
262 }
263  
264 2 ▶ if ($version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version) 2 0 2
265  
266 2 my $is_sha1 = ($version =~ /^[a-fA-F0-9]{40}$/);
267  
268 2 ▶ if ($is_sha1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_sha1) { } 1 1 2
269 1 $urls->{download} = "https://github.com/$namespace/$name/archive/$version.$file_ext";
270 }
271 else {
272 1 $urls->{download} = "https://github.com/$namespace/$name/archive/refs/tags/$version.$file_ext";
273 }
274  
275 }
276  
277 2 return $urls;
278  
279 }
280  
281 1 ▶sub _to_gitlab_urls {
Subroutine _to_gitlab_urls: called CC=5 SCAR=16.7
282  
283 1 my $purl = shift;
284  
285 1 my $name = $purl->name;
286 1 my $namespace = $purl->namespace;
287 1 my $version = $purl->version;
288 1 my $qualifiers = $purl->qualifiers;
289 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
290  
291 1 my $urls = {};
292  
293 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
294 1 $urls->{repository} = "https://gitlab.com/$namespace/$name";
295 }
296  
297 1 ▶ if ($version) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version) 1 0 1
298 1 $urls->{download} = "https://gitlab.com/$namespace/$name/-/archive/$version/$name-$version.$file_ext";
299 }
300  
301 1 return $urls;
302  
303 }
304  
305 0 ▶sub _to_golang_urls {
Subroutine _to_golang_urls: not called CC=3 SCAR=24.8
306  
307 0 my $purl = shift;
308  
309 0 my $name = $purl->name;
310 0 my $namespace = $purl->namespace;
311 0 my $version = $purl->version;
312  
313 0 my $urls = {};
314  
315 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
316 0 $urls->{repository} = "https://pkg.go.dev/$namespace/$name";
317 }
318  
319 # TODO ???
320 # if ($name && $namespace && $version) {
321 # $urls->{repository} = "https://pkg.go.dev/$namespace/$name\@v$version";
322 # }
323  
324 0 return $urls;
325  
326 }
327  
328 0 ▶sub _to_luarocks_urls {
Subroutine _to_luarocks_urls: not called CC=6 SCAR=37.4
329  
330 0 my $purl = shift;
331  
332 0 my $name = $purl->name;
333 0 my $namespace = $purl->namespace;
334 0 my $version = $purl->version;
335 0 my $qualifiers = $purl->qualifiers;
336 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
337  
338 0 ▶ if ($repository_url !~ /^(http|https):\/\//) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($repository_url =~ m[^(http|https)://]) 0 0 0
339 0 $repository_url = 'https://' . $repository_url;
340 }
341  
342 0 my $urls = {};
343  
344 0 ▶ if (!$namespace) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($namespace) 0 0 0
345 0 $urls->{repository} = "$repository_url/modules/$name";
346 }
347  
348 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
349 0 $urls->{repository} = "$repository_url/modules/$namespace/$name";
350 }
351  
352 0 return $urls;
353  
354 }
355  
356 1 ▶sub _to_maven_urls {
Subroutine _to_maven_urls: called CC=9 SCAR=29.0
357  
358 1 my $purl = shift;
359  
360 1 my $namespace = $purl->namespace;
361 1 my $name = $purl->name;
362 1 my $version = $purl->version;
363 1 my $qualifiers = $purl->qualifiers;
364 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
365 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
366  
367 1 ▶ if ($repository_url !~ /^(http|https):\/\//) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($repository_url =~ m[^(http|https)://]) 0 1 1
368 0 $repository_url = 'https://' . $repository_url;
369 }
370  
371 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
372  
373 1 (my $ns_url = $namespace) =~ s/\./\//g;
374  
375 return {
376 1 repository => "https://mvnrepository.com/artifact/$namespace/$name/$version",
377 download => "$repository_url/$ns_url/$name/$version/$name-$version.$extension"
378 };
379  
380 }
381  
382 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
383 0 return {repository => "https://mvnrepository.com/artifact/$namespace/$name"};
384 }
385  
386 }
387  
388 1 ▶sub _to_npm_urls {
Subroutine _to_npm_urls: called CC=8 SCAR=33.7
389  
390 1 my $purl = shift;
391  
392 1 my $namespace = $purl->namespace;
393 1 my $name = $purl->name;
394 1 my $version = $purl->version;
395  
396 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
397 return {
398 1 repository => "https://www.npmjs.com/package/$namespace/$name/v/$version",
399 download => "https://registry.npmjs.org/$namespace/$name/-/$name-$version.tgz"
400 };
401 }
402  
403 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
404 return {
405 0 repository => "https://www.npmjs.com/package/$name/v/$version",
406 download => "https://registry.npmjs.org/$name/-/$name-$version.tgz"
407 };
408 }
409  
410 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
411 0 return {repository => "https://www.npmjs.com/package/$namespace/$name"};
412 }
413  
414 0 return {repository => "https://www.npmjs.com/package/$name"};
415  
416 }
417  
418 1 ▶sub _to_nuget_urls {
Subroutine _to_nuget_urls: called CC=3 SCAR=12.3
419  
420 1 my $purl = shift;
421  
422 1 my $name = $purl->name;
423 1 my $version = $purl->version;
424  
425 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
426 return {
427 1 repository => "https://www.nuget.org/packages/$name/$version",
428 download => "https://www.nuget.org/api/v2/package/$name/$version"
429 };
430 }
431  
432 0 return {repository => "https://www.nuget.org/packages/$name"};
433  
434 }
435  
436 1 ▶sub _to_pypi_urls {
Subroutine _to_pypi_urls: called CC=3 SCAR=12.3
437  
438 1 my $purl = shift;
439  
440 1 my $name = $purl->name;
441 1 my $version = $purl->version;
442  
443 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
444 1 return {repository => "https://pypi.org/project/$name/$version"};
445 }
446  
447 0 return {repository => "https://pypi.org/project/$name"};
448  
449 }
450  
451 9 1;
452  
453 __END__
« PackageURL/Type.pm ↑ Summary VersionRange/Util.pm »