lib/App/githook/perltidy/install.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 10 / 10 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 90.7% 49 / 54 CC 8 SCAR 17.4
CC
8
Cov
96%
run
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.7
« lib/App/githook/perltidy/pre_commit.pm ↑ Summary lib/App/githook/perltidy/pre_commit_CI.pm »
1 package App::githook::perltidy::install;
2 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 use App::githook::perltidy::install_CI
5 9 ▶ isa => 'App::githook::perltidy',
Subroutine BEGIN: called CC=1 SCAR=0.0
6 has => {
7 absolute => {},
8 force => {},
9 9 };
10 9 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 9 our $VERSION = '1.0.1';
13  
14 6 ▶sub run {
Subroutine run: called CC=8 SCAR=20.8
Pod undocumented
15 6 my $self = shift;
16 6 my $pre_commit = $self->pre_commit;
17 6 ▶ if ( -e $pre_commit or -l $pre_commit ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $pre_commit or -l $pre_commit) 5 1 6
Condition66%2/3
-e $pre_commit or -l $pre_commit
l!l&&r!l&&!r
501
MC/DC50%1/2
-e $pre_commit or -l $pre_commit
-e $pre_commit -l $pre_commit
Truth table66%2/3
A or B
A= -e $pre_commitB= -l $pre_commit
ABresult
1X1
011
000
18 5 my $loc = $pre_commit->relative( $self->repo );
19 5 ▶ die "githook-perltidy: path already exists: $loc\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->force 1 4 5
20 . " (use --force to overwrite)\n"
21 unless $self->force;
22 }
23  
24 5 my $gp = path($0);
25 5 ▶ if ( $self->absolute ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->absolute) { } 2 3 5
26 2 $gp = $gp->realpath;
27 }
28 else {
29 3 $gp = $gp->basename;
30 }
31  
32 5 $pre_commit->parent->mkpath;
33 5 $pre_commit->spew(
34 qq{#!/bin/sh
35 if [ "\$NO_GITHOOK_PERLTIDY" != "1" ]; then
36 PERL5LIB="" $gp pre-commit
37 fi
38 }
39 );
40 5 ▶ chmod 0755, $pre_commit || warn "chmod: $!";
Condition50%1/2
$pre_commit || warn("chmod: $!")
l!l
50
MC/DC0%0/1
$pre_commit || warn("chmod: $!")
$pre_commit
Truth table50%1/2
A
A= $pre_commit
Aresult
11
00
41 5 print $pre_commit;
42 5 ▶ print " (forced)" if $self->force;
Branch: 1 branch
BranchTrueFalseTotal
if $self->force 4 1 5
43 5 ▶ print " (absolute)" if $self->absolute;
Branch: 1 branch
BranchTrueFalseTotal
if $self->absolute 2 3 5
44 5 print "\n";
45 }
46  
47 9 1;
48 __END__
« lib/App/githook/perltidy/pre_commit.pm ↑ Summary lib/App/githook/perltidy/pre_commit_CI.pm »