CpanfileSlipstop/Resolver.pm

filter: Statementstmt 100% 40 / 40 Branchbran 71.4% 10 / 14 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 8 totaltotal 80.2% 65 / 81 CC 12 SCAR 12.1
CC
12
Cov
90%
merge_snapshot_versions
6.0
ignore_module
4.3
get_version_range
3.0
CRAP 3.3
« CpanfileSlipstop/CLI.pm ↑ Summary CpanfileSlipstop.pm »
1 package App::CpanfileSlipstop::Resolver;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use CPAN::Meta::Requirements;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 17 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
8 17 my ($class, %args) = @_;
9  
10 my $self = bless +{
11 reqs => CPAN::Meta::Requirements->new,
12 cpanfile => $args{cpanfile}, # Module::CPANfile
13 snapshot => $args{snapshot}, # Carton::Snapshot
14 17 }, $class;
15  
16 17 return $self;
17 }
18  
19 231 ▶sub reqs { $_[0]->{reqs} }
Subroutine reqs: called CC=1 SCAR=0.0
Pod undocumented
20 150 ▶sub cpanfile { $_[0]->{cpanfile} }
Subroutine cpanfile: called CC=1 SCAR=0.0
Pod undocumented
21 65 ▶sub snapshot { $_[0]->{snapshot} }
Subroutine snapshot: called CC=1 SCAR=0.0
Pod undocumented
22  
23 17 ▶sub read_cpanfile_requirements {
Subroutine read_cpanfile_requirements: called CC=2 SCAR=6.9
Pod undocumented
24 17 my ($self) = @_;
25  
26 17 for my $phase (qw(configure build runtime test develop)) {
27 85 $self->reqs->add_requirements(
28 $self->cpanfile->prereqs->requirements_for($phase, 'requires')
29 );
30 }
31 # `carton install` only treats 'requires'.
32 # https://metacpan.org/source/MIYAGAWA/Carton-v1.0.34/lib/Carton/CPANfile.pm#L38
33  
34 17 return;
35 }
36  
37 18 ▶sub merge_snapshot_versions {
Subroutine merge_snapshot_versions: called CC=6 SCAR=18.0
Pod undocumented
38 18 my ($self, $merge_method, $with_core) = @_;
39  
40 18 ▶ my $find_method = $with_core ? 'find_or_core' : 'find';
Branch: 1 branch
BranchTrueFalseTotal
$with_core ? : 1 17 18
41  
42 18 my $cpanfile_modules = [ keys %{$self->reqs->as_string_hash} ];
43  
44 18 for my $module (@$cpanfile_modules) {
45 65 ▶ next if $self->ignore_module($module); # skip modules url specified
Branch: 1 branch
BranchTrueFalseTotal
if $self->ignore_module($module) 0 65 65
46  
47 65 my $installed_dist = $self->snapshot->$find_method($module);
48 65 ▶ if ($installed_dist) {
Branch: 1 branch
BranchTrueFalseTotal
if ($installed_dist) 59 6 65
49 59 my $version = $installed_dist->version_for($module);
50 59 ▶ $self->reqs->$merge_method($module, $version) if $version;
Branch: 1 branch
BranchTrueFalseTotal
if $version 59 0 59
51 }
52 }
53 }
54  
55 65 ▶sub ignore_module {
Subroutine ignore_module: called CC=4 SCAR=14.6
Pod undocumented
56 65 my ($self, $module) = @_;
57  
58 # ignore like this.
59 #
60 # requires 'Class::Enumemon',
61 # mirror => 'https://cpan.metacpan.org/',
62 # dist => 'POKUTUNA/Class-Enumemon-0.01.tar.gz';
63  
64 65 ▶ my $opts = $self->cpanfile->options_for_module($module) || {};
Condition50%1/2
$self->cpanfile->options_for_module($module) || {}
l!l
650
MC/DC0%0/1
$self->cpanfile->options_for_module($module) || {}
$self->cpanfile->options_for_module($module)
Truth table50%1/2
A
A= $self->cpanfile->options_for_module($module)
Aresult
11
00
65 65 ▶ return 1 if $opts->{dist};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"dist"} 0 65 65
66 65 ▶ return 1 if $opts->{url};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"url"} 0 65 65
67 65 return 0;
68 }
69  
70 69 ▶sub get_version_range {
Subroutine get_version_range: called CC=3 SCAR=11.0
Pod undocumented
71 69 my ($self, $module) = @_;
72  
73 69 my $version_range = $self->reqs->requirements_for_module($module);
74  
75 69 ▶ return undef if !$version_range || $version_range eq '0';
Branch: 1 branch
BranchTrueFalseTotal
if not $version_range or $version_range eq 0 10 59 69
Condition66%2/3
not $version_range or $version_range eq 0
l!l&&r!l&&!r
10059
MC/DC50%1/2
not $version_range or $version_range eq 0
not $version_range $version_range eq 0
Truth table66%2/3
not(A) or B
A= not $version_rangeB= $version_range eq 0
ABresult
1X1
011
000
76  
77 # Remove noisy '>= 0'.
78 # This causes when setting version by "add_maximum"
79 59 $version_range =~ s/\A>= 0, //;
80  
81 59 return $version_range;
82 }
83  
84 3 1;
« CpanfileSlipstop/CLI.pm ↑ Summary CpanfileSlipstop.pm »