Conformance/Update.pm

filter: Statementstmt 34.0% 15 / 44 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 40.0% 4 / 10 Podpod 100% 4 / 4 totaltotal 26.4% 23 / 87 CC 12 SCAR 30.6
CC
12
Cov
22%
write
42.0
install_hook
30.0
new
12.0
CRAP 21.2
« Conformance/Check/RefusedIniKeys.pm ↑ Summary Conformance/Check/ClaudeSettings.pm »
1 package Dist::Conformance::Update 0.006;
2  
3 # ABSTRACT: What an update changed, or would change, in a checkout, and what it left to a person
4  
5 2 ▶use 5.040;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use re '/aasx';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Mojo::Base -base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 2 has 'snapshot';
12 2 has dry_run => 0;
13 0 ▶has changes => sub { [] };
Subroutine __ANON__: not called CC=1 SCAR=1.2
14 0 ▶has manual => sub { [] };
Subroutine __ANON__: not called CC=1 SCAR=1.2
15  
16  
17 0 ▶sub new ( $class, @args ) {
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
18 0 my $self = $class->SUPER::new(@args);
19 0 my $snapshot = $self->snapshot;
20 0 ▶ die "An update needs a snapshot that it can write, such as a Dist::Conformance::Snapshot::Directory\n" if !$snapshot || !$snapshot->writable;
Branch: 1 branch
BranchTrueFalseTotal
unless $snapshot and $snapshot->writable 0 0 0
Condition0%0/3
$snapshot and $snapshot->writable
!ll&&!rl&&r
000
MC/DC0%0/2
$snapshot and $snapshot->writable
$snapshot $snapshot->writable
Truth table0%0/3
A and B
A= $snapshotB= $snapshot->writable
ABresult
0X0
100
111
21 0 return $self;
22 }
23  
24  
25 0 ▶sub write ( $self, $path, $bytes, $mode = oct 644 ) { ## no critic (Subroutines::ProhibitBuiltinHomonyms) -- a method, never called as the builtin
Subroutine write: not called CC=6 SCAR=37.4
Pod documented
26 0 my $snapshot = $self->snapshot;
27 0 my $old = $snapshot->content($path);
28 0 ▶ return 0 if defined $old && $old eq $bytes;
Branch: 1 branch
BranchTrueFalseTotal
if defined $old and $old eq $bytes 0 0 0
Condition0%0/3
defined $old and $old eq $bytes
!ll&&!rl&&r
000
MC/DC0%0/2
defined $old and $old eq $bytes
defined $old $old eq $bytes
Truth table0%0/3
A and B
A= defined $oldB= $old eq $bytes
ABresult
0X0
100
111
29 0 ▶ $snapshot->write( $path, $bytes, $mode ) if !$self->dry_run;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->dry_run 0 0 0
30 0 ▶ push @{ $self->changes }, { action => defined $old ? 'replace' : 'create', path => $path };
Branch: 1 branch
BranchTrueFalseTotal
defined $old ? : 0 0 0
31 0 return 1;
32 }
33  
34  
35 0 ▶sub install_hook ( $self, $name, $bytes ) {
Subroutine install_hook: not called CC=5 SCAR=34.0
Pod documented
36 0 my $snapshot = $self->snapshot;
37 0 my $dir = $snapshot->hooks_dir;
38 0 ▶ if ( !defined $dir ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $dir) 0 0 0
39 0 $self->by_hand( 'Install the hook ' . $name . ': ' . $snapshot->root . ' is not a git checkout' );
40 0 return 0;
41 }
42 0 my $installed = $snapshot->installed_hook($name);
43 0 ▶ return 0 if defined $installed && $installed eq $bytes;
Branch: 1 branch
BranchTrueFalseTotal
if defined $installed and $installed eq $bytes 0 0 0
Condition0%0/3
defined $installed and $installed eq $bytes
!ll&&!rl&&r
000
MC/DC0%0/2
defined $installed and $installed eq $bytes
defined $installed $installed eq $bytes
Truth table0%0/3
A and B
A= defined $installedB= $installed eq $bytes
ABresult
0X0
100
111
44 0 ▶ $snapshot->install_hook( $name, $bytes ) if !$self->dry_run;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->dry_run 0 0 0
45 0 my $hook = $dir->child($name);
46 0 push @{ $self->changes }, { action => 'install', path => $hook->to_rel( $snapshot->root )->to_string };
47 0 return 1;
48 }
49  
50  
51 0 ▶sub by_hand ( $self, @sentences ) {
Subroutine by_hand: not called CC=1 SCAR=6.9
Pod documented
52 0 push @{ $self->manual }, @sentences;
53 0 return;
54 }
55  
56 __END__
« Conformance/Check/RefusedIniKeys.pm ↑ Summary Conformance/Check/ClaudeSettings.pm »