Changelord/Role/Versions.pm

filter: Statementstmt 82.9% 39 / 47 Branchbran 40.0% 4 / 10 Conditioncond 33.3% 4 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 81.8% 9 / 11 Podpod 0.0% 0 / 4 totaltotal 61.5% 56 / 91 CC 11 SCAR 16.6
CC
11
Cov
68%
next_version
9.4
is_next
6.0
next_release
6.0
CRAP 5.3
« Changelord/Command/Init.pm ↑ Summary Changelord/Command/Add.pm »
1 package App::Changelord::Role::Versions;
2 8 our $AUTHORITY = 'cpan:YANICK';
3 8 $App::Changelord::Role::Versions::VERSION = '0.0.2';
4 8 ▶use v5.36.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 ▶use List::AllUtils qw/ first min /;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use Version::Dotted::Semantic;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 8 ▶use feature 'try';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 8 requires 'changelog';
14  
15 3 ▶sub latest_version($self){
Subroutine latest_version: called CC=2 SCAR=7.0
Pod undocumented
16 3 ▶ first { $_ } grep { $_ ne 'NEXT' } map { eval { $_->{version} || '' } } $self->changelog->{releases}->@*, { version => 'v0.0.0' };
Subroutine __ANON__: called CC=1 SCAR=0.0
Condition50%1/2
$$_{'version'} || ''
l!l
90
MC/DC0%0/1
$$_{'version'} || ''
$$_{'version'}
Truth table50%1/2
A
A= $$_{'version'}
Aresult
11
00
17 }
18  
19 2 ▶sub next_version($self) {
Subroutine next_version: called CC=8 SCAR=22.4
Pod undocumented
20 2 ▶ my $version = Version::Dotted::Semantic->new($self->latest_version // '0.0.0');
Condition50%1/2
$self->latest_version // "0.0.0"
l!l
20
MC/DC0%0/1
$self->latest_version // "0.0.0"
$self->latest_version
Truth table50%1/2
A
A= $self->latest_version
Aresult
11
00
21  
22 2 my $upcoming = $self->changelog->{releases}[0];
23  
24 2 ▶ if( $upcoming->{version} and $upcoming->{version} ne 'NEXT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($$upcoming{"version"} and $$upcoming{"version"} ne "NEXT") 0 2 2
Condition33%1/3
$$upcoming{"version"} and $$upcoming{"version"} ne "NEXT"
!ll&&!rl&&r
020
MC/DC0%0/2
$$upcoming{"version"} and $$upcoming{"version"} ne "NEXT"
$$upcoming{"version"} $$upcoming{"version"} ne "NEXT"
Truth table33%1/3
A and B
A= $$upcoming{"version"}B= $$upcoming{"version"} ne "NEXT"
ABresult
0X0
100
111
25 0 $upcoming = { changes => [] };
26 }
27  
28 my %mapping = map {
29 2 my $level = $_->{level};
30 12 map { $_ => $level } $_->{keywords}->@*
31 8 } $self->change_types->@*;
32  
33 8 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶ my $bump =min 2, map { $_ eq 'major' ? 0 : $_ eq 'minor' ? 1 : 2 } map { $mapping{$_->{type}} || 'patch' }
Branch: 2 branches
BranchTrueFalseTotal
$_ eq 'major' ? : 0 1 1
$_ eq 'minor' ? : 1 0 1
Condition50%1/2
$mapping{$$_{'type'}} || 'patch'
l!l
10
MC/DC0%0/1
$mapping{$$_{'type'}} || 'patch'
$mapping{$$_{'type'}}
Truth table50%1/2
A
A= $mapping{$$_{'type'}}
Aresult
11
00
35 1 ▶ map { ref ? $_ : { desc => $_ } }
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 1 0 1
36 2 $upcoming->{changes}->@*;
37  
38 2 $version->bump($bump);
39  
40 2 return $version->normal;
41 }
42  
43 0 ▶sub is_next($self,$release) {
Subroutine is_next: not called CC=2 SCAR=17.9
Pod undocumented
44 0 my $version = $release->{version};
45 0 ▶ return !$version || $version eq 'NEXT';
Condition0%0/3
!$version || $version eq 'NEXT'
l!l&&r!l&&!r
000
MC/DC0%0/2
!$version || $version eq 'NEXT'
!$version $version eq 'NEXT'
Truth table0%0/3
not(A) || B
A= !$versionB= $version eq 'NEXT'
ABresult
1X1
011
000
46 }
47  
48 0 ▶sub next_release($self) {
Subroutine next_release: not called CC=2 SCAR=17.9
Pod undocumented
49 0 my $changelog = $self->changelog;
50  
51 0 my $release = $changelog->{releases}[0];
52  
53 0 ▶ unless( $self->is_next($release) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->is_next($release)) 0 0 0
54 unshift $changelog->{releases}->@*,
55 0 $release = {
56 version => 'NEXT',
57 changes => [],
58 };
59 }
60  
61 0 return $release;
62 }
63  
64 8 1;
65  
66 __END__
« Changelord/Command/Init.pm ↑ Summary Changelord/Command/Add.pm »