Update/Bakefile0.pm

filter: Statementstmt 97.5% 40 / 41 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.2% 65 / 69 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/CMakefile.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.4'; # VERSION
11  
12  
13  
14 sub update_bakefile_0
15 1 ▶{
Subroutine update_bakefile_0: called CC=11 SCAR=24.0
Pod documented
16 1 my ($in, $out, $vars) = @_;
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 s{<if [^>]+>}{};
39 9 s{</if>}{};
40 9 ▶ if (m{</set>}) {
Branch: 2 branches
BranchTrueFalseTotal
if (m[</set>]) { } 2 7 9
elsif ($_) { } 6 1 7
41 # Check if we have any new files.
42 #
43 # TODO Insert them in alphabetical order.
44 2 ▶ while (my ($file, $seen) = each(%files)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %files) 7 2 9
45 7 ▶ if (!$seen) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seen) 2 5 7
46 # This file was wasn't present in the input, add it.
47 # TODO Use proper indentation.
48 2 print $out " $file\n";
49  
50 2 $changed = 1;
51 }
52 }
53  
54 2 undef $var;
55 } elsif ($_) {
56 6 ▶ if (not exists $files{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $files{$_}) 1 5 6
57 # This file was removed.
58 1 $changed = 1;
59 1 next;
60 }
61  
62 5 ▶ if ($files{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($files{$_}) { } 0 5 5
63 0 warn qq{Duplicate file "$_" in the definition of the } .
64 qq{variable "$var" at line $.\n}
65 } else {
66 5 $files{$_} = 1;
67 }
68 }
69 }
70  
71 20 print $out "$_\n";
72 }
73  
74 $changed
75 1 }
76  
77 __END__
« Update/MSBuild.pm ↑ Summary Update/CMakefile.pm »