blib/lib/File/ShouldUpdate.pm

filter: Statementstmt 94.5% 35 / 37 Branchbran 70.0% 7 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 88.5% 54 / 61 SCAR 22.1
CC
9
Cov
88%
should_update_multi
8.2
should_update
2.1
BEGIN
1.0
CRAP 9.1
↑ Summary Build »
1 package File::ShouldUpdate;
2 2 $File::ShouldUpdate::VERSION = '0.2.0';
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Time::HiRes qw/ stat /;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use vars qw/ @EXPORT_OK /;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 @EXPORT_OK = qw/ should_update should_update_multi /;
10  
11 sub should_update_multi
12 {
13 4 ▶ my ( $new_files, $syntax_sugar, $deps ) = @_;
Subroutine should_update_multi: called CC=8 SCAR=21.1
Pod documented
14 4 ▶ if ( $syntax_sugar ne ":" )
Branch: 1 branch
BranchTrueFalseTotal
if ($syntax_sugar ne ":") 0 4 4
15 {
16 0 die qq#wrong syntax_sugar - not ":"!#;
17 }
18 4 my $min_dep;
19 4 foreach my $filename2 (@$new_files)
20 {
21 6 my @stat2 = stat($filename2);
22 6 ▶ if ( !@stat2 )
Branch: 1 branch
BranchTrueFalseTotal
unless (@stat2) 2 4 6
23 {
24 2 return 1;
25 }
26 4 my $new = $stat2[9];
27 4 ▶ if ( ( !defined $min_dep ) or ( $min_dep > $new ) )
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $min_dep or $min_dep > $new) 3 1 4
Condition66%2/3
not defined $min_dep or $min_dep > $new
l!l&&r!l&&!r
301
MC/DC50%1/2
not defined $min_dep or $min_dep > $new
not defined $min_dep $min_dep > $new
Truth table66%2/3
not(A) or B
A= not defined $min_depB= $min_dep > $new
ABresult
1X1
011
000
28 {
29 3 $min_dep = $new;
30 }
31 }
32 2 foreach my $d (@$deps)
33 {
34 4 my @stat1 = stat($d);
35 4 ▶ return 1 if ( $stat1[9] > $min_dep );
Branch: 1 branch
BranchTrueFalseTotal
if $stat1[9] > $min_dep 0 4 4
36 }
37 2 return 0;
38 }
39  
40 sub should_update
41 {
42 2 ▶ my ( $filename2, $syntax_sugar, @deps ) = @_;
Subroutine should_update: called CC=2 SCAR=7.6
Pod documented
43 2 ▶ if ( $syntax_sugar ne ":" )
Branch: 1 branch
BranchTrueFalseTotal
if ($syntax_sugar ne ":") 0 2 2
44 {
45 0 die qq#wrong syntax_sugar - not ":"!#;
46 }
47 2 return should_update_multi( [$filename2], $syntax_sugar, \@deps );
48 }
49  
50 2 1;
51  
52 __END__
↑ Summary Build »