bin/wdcompile

filter: Statementstmt 96.8% 61 / 63 Branchbran 55.5% 10 / 18 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 12 / 12 Podpod n/a totaltotal 86.2% 88 / 102 CC 13 SCAR 21.6
CC
13
Cov
86%
main
15.2
BEGIN
1.0
BEGIN
1.0
CRAP 8.7
« blib/lib/WebDyne/HTML/TreeBuilder.pm ↑ Summary bin/wdlint »
1 #!/usr/bin/env perl
2 #
3 # This file is part of WebDyne.
4 #
5 # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>.
6 #
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 #
10 # Full license text is available at:
11 #
12 # <http://dev.perl.org/licenses/>
13 #
14  
15  
16 #
17 # Compile and/or show compiled version of WebDyne HTML scripts
18 #
19 package main;
20  
21  
22 # Compiler pragma, load library path
23 #
24 3 ▶use strict qw(vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
25 3 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
26 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28  
29 # Use the base modules
30 #
31 3 ▶use WebDyne::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33  
34 # External modules
35 #
36 3 ▶use WebDyne::Constant;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 3 ▶use WebDyne::Compile;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 3 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 3 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 3 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 3 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 3 ▶use FindBin qw($RealBin $Script);
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44  
45 # Local customisation
46 #
47 3 local $Data::Dumper::Indent=1;
48 3 local $Data::Dumper::Sortkeys=1;
49  
50  
51 # Version Info, must be all one line for MakeMaker, CPAN.
52 #
53 3 $VERSION='3.029';
54  
55  
56 # Run main
57 #
58 3 ▶exit ${&main(\@ARGV) || die errdump()};
Condition50%1/2
&main(\@ARGV) || die(errdump())
l!l
20
MC/DC0%0/1
&main(\@ARGV) || die(errdump())
&main(\@ARGV)
Truth table50%1/2
A
A= &main(\@ARGV)
Aresult
11
00
59  
60  
61 #===================================================================================================
62  
63  
64 3 ▶sub main {
Subroutine main: called CC=13 SCAR=27.2
65  
66  
67 # Get argv array ref
68 #
69 3 my $argv_ar=shift();
70  
71  
72 # Base options will pass to compile
73 #
74 3 my %opt=(
75  
76 no_filter => 1, # don't run through any filters
77 no_perl => 1, # don't run perl code,
78 no_timestamp => 1,
79 no_head_insert => 1,
80 manifest => 1
81  
82 #stage5 => 1, # default
83  
84 );
85  
86  
87 # Now import command line options. Command line option compilation stages are different from
88 # internal stage numbers so maps are 0=>stage0, 1=>stage2, 2=>stage3, 3=>stage4, confusing ..
89 #
90 3 ▶ GetOptions(
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions(\%opt, my(@opt) = ("stage0|0", "stage1|1", "stage2|2", "stage3|3", "stage4|4", "stage5|5|final", "meta", "data", "manifest!", "head_insert|head-insert!", "outfile|dest|dest_fn:s", "all", "timestamp!", "repeat|r|num|n=s", "perl!", "filter!", "test", "version", "help|?", "man", "dump_opt|dump-opt|opt")) or pod2usage(2) 3 0 3
91 \%opt,
92 my @opt=(
93 'stage0|0',
94 'stage1|1',
95 'stage2|2',
96 'stage3|3',
97 'stage4|4',
98 'stage5|5|final',
99 'meta',
100 'data',
101 'manifest!',
102 'head_insert|head-insert!',
103 'outfile|dest|dest_fn:s',
104 'all',
105 'timestamp!',
106 'repeat|r|num|n=s',
107 'perl!',
108 'filter!',
109 'test',
110 'version',
111 'help|?',
112 'man',
113 'dump_opt|dump-opt|opt'
114 ),
115 ) || pod2usage(2);
116 3 ▶ pod2usage(-verbose => 99, -sections => 'SYNOPSIS|OPTIONS', -exitval => 1) if $opt{'help'};
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"help"} 0 3 3
117 3 ▶ pod2usage(-verbose => 2) if $opt{'man'};
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"man"} 0 3 3
118 3 ▶ $opt{'version'} && do {
Branch: 1 branch
BranchTrueFalseTotal
$opt{"version"} and do { print "$main::Script version: $main::VERSION\n"; print "WebDyne version: $WebDyne::VERSION ($WebDyne::VERSION_GIT_SHA)\n"; exit 0 } 1 2 3
119 1 print "$Script version: $VERSION\n";
120 1 print "WebDyne version: $WebDyne::VERSION ($WebDyne::VERSION_GIT_SHA)\n";
121 1 exit 0
122 };
123  
124  
125 # Clunky, too hard to change module logic
126 #
127 2 map {$opt{"no_${_}"}=!($opt{$_})} map { /^([^|!:=+]+)/ } grep {/\!$/} @opt;
128 #map {$opt{"no${_}"}=!($opt{$_})} qw(perl filter timestamp manifest head_insert);
129 #die Dumper(\%opt);
130  
131  
132 # Get srce file, add to options
133 #
134 2 ▶ my $srce_fn=$opt{'test'} ? $WEBDYNE_DEFAULT_TEST_FN : $argv_ar->[0];
Branch: 1 branch
BranchTrueFalseTotal
$opt{'test'} ? : 0 2 2
135 2 ▶ $srce_fn ||
Branch: 1 branch
BranchTrueFalseTotal
$srce_fn or pod2usage("$main::Script: no source file specified !") 2 0 2
136 pod2usage("$Script: no source file specified !");
137 2 $opt{'srce'}=$srce_fn;
138  
139  
140 # Dump options for debugging
141 #
142 2 ▶ die Dumper(\%opt) if $opt{'dump_opt'};
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"dump_opt"} 0 2 2
143  
144  
145 # Loop if required as diagnostic for consistant compiles, i.e. making
146 # sure we haven't deleted an attribute from save data tree etc.
147 #
148 2 ▶ for (1 .. ($opt{'repeat'} || 1)) {
Condition100%2/2
$opt{'repeat'} || 1
l!l
11
MC/DC100%1/1
$opt{'repeat'} || 1
$opt{'repeat'}
Truth table100%2/2
A
A= $opt{'repeat'}
Aresult
11
00
149  
150 # Create and run compile object
151 #
152 3 my $compile_or=WebDyne::Compile->new(\%opt);
153 3 ▶ my $data_ar=$compile_or->compile(\%opt) ||
Condition50%1/2
$compile_or->compile(\%opt) || (return err())
l!l
30
MC/DC0%0/1
$compile_or->compile(\%opt) || (return err())
$compile_or->compile(\%opt)
Truth table50%1/2
A
A= $compile_or->compile(\%opt)
Aresult
11
00
154 return err();
155  
156  
157 # Dump it
158 #
159 3 ▶ if ($opt{'all'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opt{'all'}) { } 0 3 3
elsif ($opt{'meta'}) { } 3 0 3
160 0 print Dumper($data_ar);
161 }
162 elsif ($opt{'meta'}) {
163 3 print Dumper($data_ar->[0])
164 }
165 else {
166 0 print Dumper($data_ar->[1])
167 }
168  
169 }
170  
171 #print Data::Dumper::Dumper(grep {$_} $opt{'meta'} ? $data_ar->[0] : undef, $data_ar->[1]);
172  
173  
174 # Return success
175 #
176 2 return \0;
177  
178  
179 }
180  
181 __END__
« blib/lib/WebDyne/HTML/TreeBuilder.pm ↑ Summary bin/wdlint »