Conformance/Check/GitHooks.pm

filter: Statementstmt 42.5% 17 / 40 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 60.0% 6 / 10 Podpod 100% 4 / 4 totaltotal 34.6% 27 / 78 CC 10 SCAR 34.9
CC
10
Cov
29%
update
72.0
check
12.0
config_schema
2.0
CRAP 32.7
« Conformance/Check/SystemPackages.pm ↑ Summary Conformance.pm »
1 package Dist::Conformance::Check::GitHooks 0.004;
2  
3 # ABSTRACT: The git hooks are tracked, match their templates, and are installed
4  
5 1 ▶use 5.040;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use re '/aasx';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Mojo::Base 'Dist::Conformance::Check', -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Dist::Conformance::Schema();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Dist::Conformance::Snapshot();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 0 ▶sub config_schema ($) {
Subroutine config_schema: not called CC=1 SCAR=6.9
Pod documented
15 return {
16 0 required => [qw{directory hooks}],
17 properties => {
18 directory => $Dist::Conformance::Schema::PATH,
19 hooks => { type => 'object', additionalProperties => $Dist::Conformance::Schema::PATH },
20 differ => { %$Dist::Conformance::Schema::STATUS, default => 'info' },
21 replace => { type => 'boolean', default => 0 },
22 install => { type => 'boolean', default => 1 },
23 },
24 };
25 }
26  
27  
28 0 ▶sub hook_path ( $self, $name ) { return $self->config->{directory} . "/$name" }
Subroutine hook_path: not called CC=1 SCAR=6.9
Pod documented
29  
30  
31 0 ▶sub check ( $self, $snapshot ) {
Subroutine check: not called CC=3 SCAR=24.8
Pod documented
32 0 my $hooks = $self->config->{hooks};
33 0 my @names = sort keys %$hooks;
34 0 my @missing = $self->missing( $snapshot, map { $self->hook_path($_) } @names );
35 0 ▶ return ( 'fail', 'missing: ' . join ', ', @missing ) if @missing;
Branch: 1 branch
BranchTrueFalseTotal
if @missing 0 0 0
36 0 my @differ = grep { $snapshot->sha( $self->hook_path($_) ) ne Dist::Conformance::Snapshot::blob_sha( ( $self->template( $hooks->{$_} ) )[0] ) } @names;
37 0 ▶ return ( $self->config->{differ}, 'customized or outdated: ' . join ', ', map { $self->hook_path($_) } @differ ) if @differ;
Branch: 1 branch
BranchTrueFalseTotal
if @differ 0 0 0
38 0 return ( 'pass', 'match the templates' );
39 }
40  
41  
42 0 ▶sub update ( $self, $update ) {
Subroutine update: not called CC=8 SCAR=42.8
Pod documented
43 0 my ( $hooks, $replace, $install ) = @{ $self->config }{qw{hooks replace install}};
44 0 my $snapshot = $update->snapshot;
45 0 for my $name ( sort keys %$hooks ) {
46 0 my $path = $self->hook_path($name);
47 0 my ($text) = $self->template( $hooks->{$name} );
48 0 my $have = $snapshot->content($path);
49 0 ▶ if ( !defined $have || ( $replace && $have ne $text ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $have or $replace and $have ne $text) 0 0 0
Condition0%0/6
not defined $have or $replace and $have ne $text
l!l&&r!l&&!r
000
$replace and $have ne $text
!ll&&!rl&&r
000
MC/DC0%0/3
not defined $have or $replace and $have ne $text
not defined $have $replace $have ne $text
Truth table0%0/4
not(A) or B and C
A= not defined $haveB= $replaceC= $have ne $text
ABCresult
1XX1
0111
00X0
0100
50 0 ▶ $have = $text if $self->write_template( $update, $path, $hooks->{$name}, oct 755 );
Branch: 1 branch
BranchTrueFalseTotal
if $self->write_template($update, $path, $hooks->{$name}, 493) 0 0 0
51 }
52 0 ▶ $update->install_hook( $name, $have ) if $install && defined $have;
Branch: 1 branch
BranchTrueFalseTotal
if $install and defined $have 0 0 0
Condition0%0/3
$install and defined $have
!ll&&!rl&&r
000
MC/DC0%0/2
$install and defined $have
$install defined $have
Truth table0%0/3
A and B
A= $installB= defined $have
ABresult
0X0
100
111
53 }
54 0 return;
55 }
56  
57 __END__
« Conformance/Check/SystemPackages.pm ↑ Summary Conformance.pm »