Update/Bakefile0.pm

filter: Statementstmt 97.4% 38 / 39 Branchbran 94.4% 17 / 18 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 94.0% 63 / 67 CC 11 SCAR 21.8
CC
11
Cov
95%
update_bakefile_0
11.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.9
« Update/MSBuild.pm ↑ Summary Update.pm »
1 package Makefile::Update::Bakefile0;
2 # ABSTRACT: Update bakefile-0.x files list.
3  
4 1 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 our @EXPORT = qw(update_bakefile_0);
6  
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  
10 1 our $VERSION = '0.2'; # VERSION
11  
12  
13  
14 sub update_bakefile_0
15 {
16 1 ▶ my ($in, $out, $vars) = @_;
Subroutine update_bakefile_0: called CC=11 SCAR=24.0
Pod documented
17  
18 # Variable whose contents is being currently replaced.
19 1 my $var;
20  
21 # Hash with files defined for the specified variable as keys and 0 or 1
22 # depending on whether we have seen them in the input file as values.
23 my %files;
24  
25 # Set to 1 if we made any changes.
26 1 my $changed = 0;
27 1 ▶ while (<$in>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $in)) 21 1 22
28 21 chomp;
29  
30 21 ▶ if (/<set var="(\w+)" hints="files">/ && exists $vars->{$1}) {
Branch: 2 branches
BranchTrueFalseTotal
if (/<set var="(\w+)" hints="files">/ and exists $vars->{$1}) { } 2 19 21
elsif (defined $var) { } 9 10 19
Condition66%2/3
/<set var="(\w+)" hints="files">/ and exists $vars->{$1}
!ll&&!rl&&r
1902
MC/DC50%1/2
/<set var="(\w+)" hints="files">/ and exists $vars->{$1}
/<set var="(\w+)" hints="files">/ exists $vars->{$1}
Truth table66%2/3
A and B
A= /<set var="(\w+)" hints="files">/B= exists $vars->{$1}
ABresult
0X0
100
111
31 2 $var = $1;
32 2 %files = map { $_ => 0 } @{$vars->{$var}};
33 } elsif (defined $var) {
34 9 local $_ = $_;
35 9 s/<!-- .* -->//;
36 9 s/^\s+//;
37 9 s/\s+$//;
38 9 ▶ if (m{</set>}) {
Branch: 2 branches
BranchTrueFalseTotal
if (m[</set>]) { } 2 7 9
elsif ($_) { } 6 1 7
39 # Check if we have any new files.
40 #
41 # TODO Insert them in alphabetical order.
42 2 ▶ while (my ($file, $seen) = each(%files)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %files) 7 2 9
43 7 ▶ if (!$seen) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seen) 2 5 7
44 # This file was wasn't present in the input, add it.
45 # TODO Use proper indentation.
46 2 print $out " $file\n";
47  
48 2 $changed = 1;
49 }
50 }
51  
52 2 undef $var;
53 } elsif ($_) {
54 6 ▶ if (not exists $files{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $files{$_}) 1 5 6
55 # This file was removed.
56 1 $changed = 1;
57 1 next;
58 }
59  
60 5 ▶ if ($files{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($files{$_}) { } 0 5 5
61 0 warn qq{Duplicate file "$_" in the definition of the } .
62 qq{variable "$var" at line $.\n}
63 } else {
64 5 $files{$_} = 1;
65 }
66 }
67 }
68  
69 20 print $out "$_\n";
70 }
71  
72 $changed
73 1 }
74  
75 __END__
« Update/MSBuild.pm ↑ Summary Update.pm »