blib/lib/App/MacVictimUtils.pm

filter: Statementstmt 55.1% 16 / 29 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 66.6% 4 / 6 Podpod 100% 1 / 1 totaltotal 42.0% 21 / 50 CC 6 SCAR 27.1
CC
6
Cov
40%
__ANON__
30.0
delete_ds_store
6.0
BEGIN
1.0
CRAP 15.1
↑ Summary
1 package App::MacVictimUtils;
2  
3 1 our $DATE = '2021-05-25'; # DATE
4 1 our $VERSION = '0.002'; # VERSION
5  
6 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Log::ger;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our %SPEC;
12  
13 $SPEC{delete_ds_store} = {
14 1 v => 1.1,
15 summary => 'Recursively delete .DS_Store files',
16 args => {
17 dirs => {
18 schema => ['array*', of=>'dirname*'],
19 pos => 0,
20 greedy => 1,
21 },
22 },
23 features => {
24 dry_run => 1,
25 },
26 };
27 0 ▶sub delete_ds_store {
Subroutine delete_ds_store: not called CC=2 SCAR=17.9
Pod documented
28 0 require File::Find;
29  
30 0 my %args = @_;
31  
32 0 ▶ my @dirs = @{ $args{dirs} || ["."] };
Condition0%0/2
$args{'dirs'} || ['.']
l!l
00
MC/DC0%0/1
$args{'dirs'} || ['.']
$args{'dirs'}
Truth table0%0/2
A
A= $args{'dirs'}
Aresult
11
00
33  
34 File::Find::find(
35 0 ▶ sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
36 0 ▶ return unless -f && $_ eq '.DS_Store';
Branch: 1 branch
BranchTrueFalseTotal
unless -f $_ and $_ eq ".DS_Store" 0 0 0
Condition0%0/3
-f $_ and $_ eq ".DS_Store"
!ll&&!rl&&r
000
MC/DC0%0/2
-f $_ and $_ eq ".DS_Store"
-f $_ $_ eq ".DS_Store"
Truth table0%0/3
A and B
A= -f $_B= $_ eq ".DS_Store"
ABresult
0X0
100
111
37 0 ▶ if ($args{-dry_run}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"-dry_run"}) 0 0 0
38 0 log_info("[DRY] Deleting %s/.DS_Store ...", $File::Find::dir);
39 0 return;
40 }
41 0 log_info("Deleting %s/.DS_Store ...", $File::Find::dir);
42 0 ▶ unlink $_ or do {
Branch: 1 branch
BranchTrueFalseTotal
unlink $_ or do { log_warn("Can't delete %s/.DS_Store: %s", $File::Find::dir, $!) } 0 0 0
43 0 log_warn("Can't delete %s/.DS_Store: %s", $File::Find::dir, $!);
44 };
45 },
46 0 @dirs,
47 );
48 0 [200];
49 }
50  
51 1 1;
52 # ABSTRACT: CLI utilities for when dealing with Mac computers/files
53  
54 __END__
↑ Summary