util/ppixref

filter: Statementstmt 52.4% 96 / 183 Branchbran 40.5% 30 / 74 Conditioncond 33.3% 11 / 33 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 54.8% 17 / 31 Podpod n/a totaltotal 45.7% 154 / 337 SCAR 47.6
CC
25
Cov
47%
__ANON__
13.3
emit
9.2
__ANON__
6.0
CRAP 116.8
« blib/lib/PPI/Xref.pm ↑ Summary
1 #!/usr/bin/env perl
2  
3 1 ▶use PPI::Xref;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use File::Basename qw[basename];
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 my $ME = basename($0);
10  
11 1 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 Getopt::Long::Configure(qw[no_auto_abbrev]);
13  
14 sub short_help_string {
15 0 ▶ return <<__EOU__;
Subroutine short_help_string: not called CC=1 SCAR=6.9
16 $ME: Usage:
17 $ME [--files|--subs|--packages|--modules|--missing_modules|--parse_errors] ...
18 $ME [--subs_files|--packages_files] ...
19 $ME [--files_lines|--total_lines] ...
20 $ME [--incs_files|--incs_chains|--incs_chains_reverse|--incs_deps] ...
21 $ME [--files_founts|--modules_counts] ...
22 $ME [--code=... [--auto_semicolon]]
23 $ME --parse
24 $ME --report_all
25 $ME --report_title
26 $ME --report_prefix=prefix
27 $ME --INC=dir,dir,dir
28 $ME --cache_directory=dir
29 $ME [--process_verbose|--recurse_verbose|--cache_verbose|--summary]
30 $ME [--separator=s|--column|--finish]
31 $ME --recurse|--norecurse
32 $ME [--help|--longhelp]
33 __EOU__
34 }
35  
36 sub help {
37 0 ▶ die short_help_string();
Subroutine help: not called CC=1 SCAR=6.9
38 }
39  
40 sub long_help {
41 0 ▶ print short_help_string();
Subroutine long_help: not called CC=1 SCAR=6.9
42 0 die <<__EOU__;
43  
44 The ... is either a list of files, or --code='...', or --files_from_file=file,
45 or --files_from_cache, or --files_from_system.
46  
47 If --code is used, the filename is faked to be '-' in the reports.
48 The --files_from_file=file specifies a file to read the filenames
49 from, filename per line. If the filename is '-', STDIN is used.
50  
51 Note that the --code argument must be complete, e.g. 'use utf8;' must
52 have the semicolon. For convenience, a semicolon is automatically added
53 unless there already is one, or the code argument ends in an end brace.
54 This can be disabled with --noauto_semicolon.
55  
56 The --parse can be used to just parse the inputs (and possibly cache
57 the results, if --cache_directory is specified) but not to output
58 anything (except the --*verbose or --summary output). One or more
59 of --parse or one of the report options (--packages et cetera,
60 read on) must be specified.
61  
62 An "inc" is a "file inclusion", any of the use/no/require/do.
63  
64 * --packages shows seen package statements, while the --modules shows
65 module names included via use/no/require.
66  
67 * --missing_modules (default: on) shows the missing modules (in addition
68 to warning about them during scan). Use --nomissing_modules to suppress.
69  
70 * --parse_errors (default: on) shows the parse errors modules (in addition
71 to warning about them during scan). Use --noparse_errors to suppress.
72  
73 * --subs_files, --packages_files, and --incs_files by default show only
74 the start line, with --finish they show also the finish, and with
75 --column also the column(s). The --incs_chains only shows the start lines.
76  
77 * --incs_files shows only the first level, the --incs_chains shows the
78 full inclusion chains. Warning: the number of inclusion chains can be
79 even for the simplest codes. Enjoy responsibly.
80  
81 * --incs_chains_reverse instead of --incs_chains generates reversed
82 inclusion chains, for inspecting reverse dependencies.
83  
84 * --total_lines tells the total number of lines seen, while the
85 --files_lines tells the lines per file.
86  
87 * --files_counts and --modules_counts show how many times each file
88 or module is referred to (first-level).
89  
90 * --incs_deps shows what kind of tree node (root, branch, leaf, singleton)
91 each file is in the total dependency tree. It does not attempt to draw
92 the actual tree graph.
93  
94 * --report_all turns on all the reports. By default these reports go
95 to STDOUT, with --report_prefix you can direct them to files starting
96 with the specified prefix. The report titles ("===...===") can be
97 turned off with --noreport_title.
98  
99 The --cache_directory=dir can be used to cache the PPI processing results
100 under a directory. This is usually much faster than processing the
101 files from scratch with PPI. For paranoia, the directory must exist.
102  
103 The --INC=dir,dir,dir can be used to specify an \@INC different from the
104 standard one. Note the comma-separation.
105  
106 The --separator default is the tabulator.
107  
108 The default is to recurse through use/no/require/do statements,
109 use --norecurse to not to.
110  
111 The --summary (default: on) turns on summary report at the end.
112 The --processverbose turns on display on processing progress.
113 The --cacheverbose turns on verbose cache access.
114 __EOU__
115 }
116  
117 1 my %OptDefault = (
118 separator => "\t",
119 recurse => 1,
120 report_title => 1,
121 missing_modules => 1,
122 parse_errors => 1,
123 auto_semicolon => 1,
124 );
125  
126 1 my %Opt = %OptDefault;
127  
128 help() unless GetOptions('files' => \$Opt{files},
129 'subs' => \$Opt{subs},
130 'packages' => \$Opt{packages},
131 'modules' => \$Opt{modules},
132 'missing_modules' => \$Opt{missing_modules},
133 'parse_errors' => \$Opt{parse_errors},
134 'total_lines' => \$Opt{total_lines},
135 'files_lines' => \$Opt{files_lines},
136 'subs_files' => \$Opt{subs_files},
137 'packages_files' => \$Opt{packages_files},
138 'incs_files' => \$Opt{incs_files},
139 'incs_chains' => \$Opt{incs_chains},
140 'incs_chains_reverse' => \$Opt{incs_chains_reverse},
141 'files_counts' => \$Opt{files_counts},
142 'modules_counts' => \$Opt{modules_counts},
143 'incs_deps' => \$Opt{incs_deps},
144 'parse' => \$Opt{parse},
145 'report_all' => \$Opt{report_all},
146 'report_prefix=s' => \$Opt{report_prefix},
147 'INC=s' => \$Opt{INC},
148 'cache_directory=s' => \$Opt{cache_directory},
149 'code=s' => \$Opt{code},
150 'auto_semicolon' => \$Opt{auto_semicolon},
151 'files_from_file=s' => \$Opt{files_from_file},
152 'files_from_cache' => \$Opt{files_from_cache},
153 'files_from_system' => \$Opt{files_from_system},
154 'process_verbose' => \$Opt{process_verbose},
155 'recurse_verbose' => \$Opt{recurse_verbose},
156 'cache_verbose' => \$Opt{cache_verbose},
157 'summary' => \$Opt{summary},
158 'separator=s' => \$Opt{separator},
159 'recurse!' => \$Opt{recurse},
160 'column' => \$Opt{column},
161 'finish' => \$Opt{finish},
162 'help' => \$Opt{help},
163 1 ▶ 'longhelp' => \$Opt{longhelp});
Branch: 1 branch
BranchTrueFalseTotal
unless &GetOptions("files", \$Opt{"files"}, "subs", \$Opt{"subs"}, "packages", \$Opt{"packages"}, "modules", \$Opt{"modules"}, "missing_modules", \$Opt{"missing_modules"}, "parse_errors", \$Opt{"parse_errors"}, "total_lines", \$Opt{"total_lines"}, "files_lines", \$Opt{"files_lines"}, "subs_files", \$Opt{"subs_files"}, "packages_files", \$Opt{"packages_files"}, "incs_files", \$Opt{"incs_files"}, "incs_chains", \$Opt{"incs_chains"}, "incs_chains_reverse", \$Opt{"incs_chains_reverse"}, "files_counts", \$Opt{"files_counts"}, "modules_counts", \$Opt{"modules_counts"}, "incs_deps", \$Opt{"incs_deps"}, "parse", \$Opt{"parse"}, "report_all", \$Opt{"report_all"}, "report_prefix=s", \$Opt{"report_prefix"}, "INC=s", \$Opt{"INC"}, "cache_directory=s", \$Opt{"cache_directory"}, "code=s", \$Opt{"code"}, "auto_semicolon", \$Opt{"auto_semicolon"}, "files_from_file=s", \$Opt{"files_from_file"}, "files_from_cache", \$Opt{"files_from_cache"}, "files_from_system", \$Opt{"files_from_system"}, "process_verbose", \$Opt{"process_verbose"}, "recurse_verbose", \$Opt{"recurse_verbose"}, "cache_verbose", \$Opt{"cache_verbose"}, "summary", \$Opt{"summary"}, "separator=s", \$Opt{"separator"}, "recurse!", \$Opt{"recurse"}, "column", \$Opt{"column"}, "finish", \$Opt{"finish"}, "help", \$Opt{"help"}, "longhelp", \$Opt{"longhelp"}) 0 1 1
164  
165 1 ▶help() if $Opt{help};
Branch: 1 branch
BranchTrueFalseTotal
if $Opt{"help"} 0 1 1
166 1 ▶long_help() if $Opt{longhelp};
Branch: 1 branch
BranchTrueFalseTotal
if $Opt{"longhelp"} 0 1 1
167  
168 1 my @ACTION = qw[files subs packages modules missing_modules parse_errors
169 subs_files packages_files files_lines total_lines
170 files_counts modules_counts
171 incs_files incs_deps incs_chains incs_chains_reverse];
172
173 1 ▶if ($Opt{report_all}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"report_all"}) 0 1 1
174 0 @Opt{@ACTION} = (1) x @ACTION;
175 }
176  
177 1 ▶use List::Util qw[any];
Subroutine BEGIN: called CC=1 SCAR=0.0
178 1 ▶help() unless (any { $Opt{$_} }
Subroutine __ANON__: called CC=1 SCAR=0.0
179 16 grep { ! $OptDefault{$_} }
180 @ACTION) ||
181 1 ▶ $Opt{parse};
Branch: 1 branch
BranchTrueFalseTotal
unless &any(sub { $Opt{$_}; } , grep({not $OptDefault{$_};} @ACTION)) or $Opt{"parse"} 0 1 1
Condition33%1/3
&any(sub { $Opt{$_}; } , grep({not $OptDefault{$_};} @ACTION)) or $Opt{"parse"}
l!l&&r!l&&!r
100
MC/DC0%0/2
&any(sub { $Opt{$_}; } , grep({not $OptDefault{$_};} @ACTION)) or $Opt{"parse"}
&any(sub { $Opt{$_}; } , grep({not $OptDefault{$_};} @ACTION)) $Opt{"parse"}
Truth table33%1/3
A or B
A= &any(sub { $Opt{$_}; } , grep({not $OptDefault{$_};} @ACTION))B= $Opt{"parse"}
ABresult
1X1
011
000
182  
183 1 ▶$Opt{separator} = "\t" if $Opt{separator} eq '\t'; # Nicer to type in shells.
Branch: 1 branch
BranchTrueFalseTotal
if $Opt{"separator"} eq "\\t" 0 1 1
184  
185 1 ▶if ($Opt{process_verbose} ||
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"process_verbose"} or $Opt{"recurse_verbose"} or $Opt{"cache_verbose"} or $Opt{"summary"}) 0 1 1
Condition33%3/9
$Opt{"process_verbose"} or $Opt{"recurse_verbose"} or $Opt{"cache_verbose"} or $Opt{"summary"}
l!l&&r!l&&!r
001
$Opt{"process_verbose"} or $Opt{"recurse_verbose"} or $Opt{"cache_verbose"}
l!l&&r!l&&!r
001
$Opt{"process_verbose"} or $Opt{"recurse_verbose"}
l!l&&r!l&&!r
001
MC/DC0%0/4
$Opt{"process_verbose"} or $Opt{"recurse_verbose"} or $Opt{"cache_verbose"} or $Opt{"summary"}
$Opt{"process_verbose"} $Opt{"recurse_verbose"} $Opt{"cache_verbose"} $Opt{"summary"}
Truth table0%0/5
A or B or C or D
A= $Opt{"process_verbose"}B= $Opt{"recurse_verbose"}C= $Opt{"cache_verbose"}D= $Opt{"summary"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
186 $Opt{recurse_verbose} ||
187 $Opt{cache_verbose} ||
188 $Opt{summary}) {
189 0 select(STDOUT); $| = 1;
190 }
191  
192 my $xref_opt = {
193 process_verbose => $Opt{process_verbose},
194 recurse_verbose => $Opt{recurse_verbose},
195 cache_verbose => $Opt{cache_verbose},
196 recurse => $Opt{recurse},
197 1 };
198  
199 1 ▶if (defined $Opt{INC}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Opt{"INC"}) 0 1 1
200 0 $xref_opt->{INC} = [ split(',', $Opt{INC}) ];
201 }
202  
203 1 ▶if (defined $Opt{cache_directory}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Opt{"cache_directory"}) 0 1 1
204 0 ▶ unless (-d $Opt{cache_directory} && -r $Opt{cache_directory} && -w $Opt{cache_directory}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $Opt{"cache_directory"} and -r $Opt{"cache_directory"} and -w $Opt{"cache_directory"}) 0 0 0
Condition0%0/6
-d $Opt{"cache_directory"} and -r $Opt{"cache_directory"} and -w $Opt{"cache_directory"}
!ll&&!rl&&r
000
-d $Opt{"cache_directory"} and -r $Opt{"cache_directory"}
!ll&&!rl&&r
000
MC/DC0%0/3
-d $Opt{"cache_directory"} and -r $Opt{"cache_directory"} and -w $Opt{"cache_directory"}
-d $Opt{"cache_directory"} -r $Opt{"cache_directory"} -w $Opt{"cache_directory"}
Truth table0%0/4
A and B and C
A= -d $Opt{"cache_directory"}B= -r $Opt{"cache_directory"}C= -w $Opt{"cache_directory"}
ABCresult
0XX0
10X0
1100
1111
205 0 warn "$ME: Not a read-write directory --cache_directory='$Opt{cache_directory}'\n";
206 }
207 0 $xref_opt->{cache_directory} = $Opt{cache_directory};
208 }
209  
210 1 my $xref = PPI::Xref->new($xref_opt);
211  
212 1 package Times {
213 1 ▶ use Time::HiRes ();
Subroutine BEGIN: called CC=1 SCAR=0.0
214 3 ▶ sub get { bless [ Time::HiRes::time(), times() ] }
Subroutine get: called CC=1 SCAR=0.0
215 sub diff {
216 0 ▶ my @d = map { $_[0]->[$_] - $_[1]->[$_] } 0..2;
Subroutine diff: not called CC=1 SCAR=6.9
217 0 return (@d, $d[1] + $d[2]);
218 }
219 }
220  
221 1 my $t0 = Times->get();
222  
223 1 ▶if (defined $Opt{files_from_file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Opt{"files_from_file"}) 0 1 1
224 0 my $fh;
225 0 ▶ if ($Opt{files_from_file} eq '-') {
Branch: 2 branches
BranchTrueFalseTotal
if ($Opt{'files_from_file'} eq '-') { } 0 0 0
elsif (not open($fh, '<', $Opt{'files_from_file'})) { } 0 0 0
226 0 $fh = *STDIN;
227 } elsif (!open($fh, '<', $Opt{files_from_file})) {
228 0 warn "$ME: Failed to open --files_from_file='$Opt{files_from_file}': $!\n";
229 }
230 1 ▶ use Scalar::Util qw[openhandle];
Subroutine BEGIN: called CC=1 SCAR=0.0
231 0 ▶ if (openhandle($fh)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&openhandle($fh)) { } 0 0 0
232 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
233 0 chomp;
234 0 ▶ unless ($xref->process($_)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($xref->process($_)) 0 0 0
235 0 warn "$ME: Failed to process '$_'\n";
236 }
237 }
238 } else {
239 0 help();
240 }
241 }
242 1 ▶if (defined $Opt{files_from_cache}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Opt{"files_from_cache"}) 0 1 1
243 0 $xref->process_files_from_cache();
244 }
245 1 ▶if (defined $Opt{files_from_system}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Opt{"files_from_system"}) 0 1 1
246 0 $xref->process_files_from_system();
247 }
248 1 ▶if (defined $Opt{code}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Opt{"code"}) 1 0 1
249 1 ▶ if ($Opt{auto_semicolon}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"auto_semicolon"}) 1 0 1
250 1 ▶ unless ($Opt{code} =~ /[;}]\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Opt{"code"} =~ /[;}]\s*$/) 1 0 1
251 1 $Opt{code} .= ';';
252 }
253 }
254 1 $xref->process(\$Opt{code});
255 }
256 1 ▶if (@ARGV) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ARGV) 0 1 1
257 0 $xref->process(@ARGV);
258 }
259  
260 1 my $t1 = Times->get();
261  
262 sub emit {
263 6 ▶ my ($xref, $opt, $cb) = @_;
Subroutine emit: called CC=8 SCAR=22.2
264 6 my $fh;
265 6 ▶ if (defined $Opt{report_prefix}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Opt{'report_prefix'}) { } 0 6 6
266 0 my $fn = $Opt{report_prefix} . "$opt.txt";
267 0 ▶ open($fh, ">", $fn) or die qq[$0: Failed to create "$fn": $!\n];
Branch: 1 branch
BranchTrueFalseTotal
open $fh, ">", $fn or die qq[$0: Failed to create "$fn": $!\n] 0 0 0
268 0 print "$ME: Created $fn\n";
269 } else {
270 6 $fh = *STDOUT;
271 }
272 6 my $report_title = $Opt{report_title};;
273 6 ▶ if (($opt eq 'missing_modules' && !$xref->missing_modules) ||
Branch: 1 branch
BranchTrueFalseTotal
if ($opt eq "missing_modules" and not $xref->missing_modules or $opt eq "parse_errors" and not $xref->parse_errors_files) 2 4 6
Condition77%7/9
$opt eq "missing_modules" and not $xref->missing_modules or $opt eq "parse_errors" and not $xref->parse_errors_files
l!l&&r!l&&!r
132
$opt eq "missing_modules" and not $xref->missing_modules
!ll&&!rl&&r
501
$opt eq "parse_errors" and not $xref->parse_errors_files
!ll&&!rl&&r
401
MC/DC0%0/4
$opt eq "missing_modules" and not $xref->missing_modules or $opt eq "parse_errors" and not $xref->parse_errors_files
$opt eq "missing_modules" not $xref->missing_modules $opt eq "parse_errors" not $xref->parse_errors_files
Truth table28%2/7
A and not(B) or C and not(D)
A= $opt eq "missing_modules"B= not $xref->missing_modulesC= $opt eq "parse_errors"D= not $xref->parse_errors_files
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
274 ($opt eq 'parse_errors' && !$xref->parse_errors_files)) {
275 2 $report_title = 0;
276 }
277 6 ▶ print { $fh } "=== $opt ===\n" if $report_title;
Branch: 1 branch
BranchTrueFalseTotal
if $report_title 4 2 6
278 6 $cb->($xref, $fh);
279 }
280  
281 1 ▶unless ($Opt{parse}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Opt{"parse"}) 1 0 1
282 my %cb = (
283 files => sub {
284 1 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
285 1 for my $f ($xref->files) {
286 2 print { $fh } $f, "\n";
287 }
288 },
289 subs => sub{
290 1 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
291 1 for my $s ($xref->subs) {
292 2 print { $fh } $s, "\n";
293 }
294 },
295 packages => sub {
296 0 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
297 0 for my $p ($xref->packages) {
298 0 print { $fh } $p, "\n";
299 }
300 },
301 modules => sub {
302 0 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
303 0 for my $p ($xref->modules) {
304 0 print { $fh } $p, "\n";
305 }
306 },
307 total_lines => sub {
308 0 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
309 0 print { $fh } $xref->total_lines, "\n";
310 },
311 files_lines => sub {
312 0 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
313 0 for my $f ($xref->files) {
314 0 print { $fh } $f, $Opt{separator}, $xref->file_lines($f), "\n";
315 }
316 },
317 files_counts => sub {
318 0 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
319 0 for my $f ($xref->files) {
320 0 print { $fh } $f, $Opt{separator}, $xref->file_count($f), "\n";
321 }
322 },
323 modules_counts => sub {
324 0 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
325 0 for my $f ($xref->modules) {
326 0 print { $fh } $f, $Opt{separator}, $xref->module_count($f), "\n";
327 }
328 },
329 missing_modules => sub {
330 1 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: called CC=2 SCAR=9.2
331 1 for my $m ($xref->missing_modules) {
332 0 print { $fh } $m, $Opt{separator}, $xref->missing_module_count($m), $Opt{separator}, join($Opt{separator}, $xref->missing_module_lines($m)), "\n";
333 }
334 },
335 parse_errors => sub {
336 1 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: called CC=4 SCAR=25.8
337 1 for my $f ($xref->parse_errors_files) {
338 0 my %e = $xref->file_parse_errors($f);
339 0 ▶ my @e = map { defined $e{$_} ? "$e{$_}" : $_ }
Branch: 1 branch
BranchTrueFalseTotal
defined $e{$_} ? : 0 0 0
340 0 ▶ sort { $a cmp $b || $e{$a} cmp $e{$b} }
Branch: 1 branch
BranchTrueFalseTotal
$a cmp $b or $e{$a} cmp $e{$b} 0 0 0
341 sort keys %e;
342 0 print { $fh } $f, $Opt{separator}, "@e\n";
343 }
344 },
345 incs_deps => sub {
346 0 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
347 0 my $id = $xref->incs_deps;
348 0 for my $f ($id->files) {
349 0 print { $fh } $f, $Opt{separator}, $id->file_kind($f), "\n";
350 }
351 },
352 subs_files => sub {
353 1 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
354 my $sfi = $xref->subs_files_iter({separator => $Opt{separator},
355 column => $Opt{column},
356 1 finish => $Opt{finish}});
357 1 ▶ while (my $sf = $sfi->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sf = $sfi->next) 2 1 3
358 2 print { $fh } $sf->string, "\n";
359 }
360 },
361 packages_files => sub {
362 0 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
363 my $pfi = $xref->packages_files_iter({separator => $Opt{separator},
364 column => $Opt{column},
365 0 finish => $Opt{finish}});
366 0 ▶ while (my $pf = $pfi->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pf = $pfi->next) 0 0 0
367 0 print { $fh } $pf->string, "\n";
368 }
369 },
370 incs_files => sub {
371 1 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
372 my $ifi = $xref->incs_files_iter({separator => $Opt{separator},
373 column => $Opt{column},
374 1 finish => $Opt{finish}});
375 1 ▶ while (my $if = $ifi->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $if = $ifi->next) 1 1 2
376 1 print { $fh } $if->string, "\n";
377 }
378 },
379 incs_chains => sub {
380 0 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
381 0 my $ici = $xref->incs_chains_iter({separator => $Opt{separator}});
382 0 ▶ while (my $ic = $ici->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ic = $ici->next) 0 0 0
383 0 print { $fh } $ic->string, "\n";
384 }
385 },
386 incs_chains_reverse => sub {
387 0 ▶ my ($xref, $fh) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
388 my $ici = $xref->incs_chains_iter({separator => $Opt{separator},
389 0 reverse_chains => 1});
390 0 ▶ while (my $ic = $ici->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ic = $ici->next) 0 0 0
391 0 print { $fh } $ic->string, "\n";
392 }
393 },
394 1 );
395 1 for my $opt (@ACTION) {
396 16 ▶ if ($Opt{$opt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{$opt}) 6 10 16
397 6 ▶ die qq[$ME: Unexpected callback '$opt'\n] unless defined $cb{$opt};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cb{$opt} 0 6 6
398 6 emit($xref, $opt, $cb{$opt});
399 }
400 }
401 }
402  
403 1 my $t2 = Times->get();
404  
405 1 ▶if ($Opt{summary}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Opt{"summary"}) 0 1 1
406 0 my ($dw1, $du1, $ds1, $dc1) = $t1->diff($t0);
407 0 ▶ printf("$ME: files=%d lines=%d subs=%d\n",
Condition0%0/6
$xref->files || 0
l!l
00
$xref->total_lines || 0
l!l
00
$xref->subs || 0
l!l
00
MC/DC0%0/1
$xref->files || 0
$xref->files
MC/DC0%0/1
$xref->total_lines || 0
$xref->total_lines
MC/DC0%0/1
$xref->subs || 0
$xref->subs
Truth table0%0/2
A
A= $xref->files
Aresult
11
00
Truth table0%0/2
A
A= $xref->total_lines
Aresult
11
00
Truth table0%0/2
A
A= $xref->subs
Aresult
11
00
408 $xref->files || 0,
409 $xref->total_lines || 0,
410 $xref->subs || 0);
411 0 printf("$ME: docs_created=%d cache reads=%d writes=%d updates=%d creates=%d deletes=%d\n",
412 $xref->docs_created,
413 $xref->cache_reads,
414 $xref->cache_writes,
415 $xref->cache_updates,
416 $xref->cache_creates,
417 $xref->cache_deletes);
418 0 printf("$ME: parse: wall=%.2fs user=%.2fs system=%.2fs cpu=%.2fs\n",
419 $dw1, $du1, $ds1, $dc1);
420 0 my ($dw2, $du2, $ds2, $dc2) = $t2->diff($t1);
421 0 printf("$ME: output: wall=%.2fs user=%.2fs system=%.2fs cpu=%.2fs\n",
422 $dw2, $du2, $ds2, $dc2);
423 }
424  
425 1 exit(0);
« blib/lib/PPI/Xref.pm ↑ Summary