blib/lib/ShipIt/Step/CheckVersionsMatch.pm

filter: Statementstmt 51.8% 14 / 27 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 100% 1 / 1 totaltotal 38.7% 19 / 49 CC 8 SCAR 28.9
CC
8
Cov
35%
run
30.0
_version_from_file
20.0
BEGIN
1.0
CRAP 18.0
↑ Summary
1 package ShipIt::Step::CheckVersionsMatch;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use base 'ShipIt::Step';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use File::Find::Rule;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 1 our $VERSION = '0.02';
12  
13 0 ▶sub run {
Subroutine run: not called CC=5 SCAR=34.0
Pod documented
14 0 my $self = shift;
15 0 my $state = shift;
16  
17 0 my $master_version = $state->version();
18  
19 0 for my $mod ( File::Find::Rule->name('*.pm')->in('lib') )
20 {
21 0 my $version = $self->_version_from_file($mod);
22 0 ▶ next unless defined $version && length $version;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version and length $version 0 0 0
Condition0%0/3
defined $version and length $version
!ll&&!rl&&r
000
MC/DC0%0/2
defined $version and length $version
defined $version length $version
Truth table0%0/3
A and B
A= defined $versionB= length $version
ABresult
0X0
100
111
23  
24 0 ▶ if ( $version ne $master_version )
Branch: 1 branch
BranchTrueFalseTotal
if ($version ne $master_version) 0 0 0
25 {
26 0 die "The version in $mod ($version) does not match the master version ($master_version)\n";
27 }
28 }
29 }
30  
31 # Copied from ProjectType::Perl, which operates only on $self->{ver_from}
32 sub _version_from_file
33 0 ▶{
Subroutine _version_from_file: not called CC=4 SCAR=30.0
34 0 my $self = shift;
35 0 my $file = shift;
36  
37 0 ▶ open my $fh, '<', $file
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $file or die "Failed to open ${file}: $!\n" 0 0 0
38 or die "Failed to open $file: $!\n";
39  
40 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
41 0 ▶ return $2 if /\$VERSION\s*=\s*([\'\"])(.+?)\1/;
Branch: 1 branch
BranchTrueFalseTotal
if /\$VERSION\s*=\s*([\'\"])(.+?)\1/ 0 0 0
42 }
43 }
44  
45  
46 1 1;
47  
48 __END__
↑ Summary