blib/lib/uninit.pm

filter: Statementstmt 61.1% 11 / 18 Branchbran 41.6% 5 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 48.6% 18 / 37 CC 8 SCAR 28.1
CC
8
Cov
48%
CHECK
18.6
BEGIN
1.0
CRAP 16.6
↑ Summary
1 package uninit;
2  
3 1 $uninit::VERSION="1.00";
4  
5 1 ▶CHECK {
Subroutine CHECK: called CC=8 SCAR=29.2
6 1 ▶ use B qw(main_start);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 my %globs;
8 1 my ($prog, $line);
9 1 ▶ for (my $op = main_start; $$op; $op = $op->next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$op) 7 1 8
10 7 ▶ if ($op->name =~ /gvsv/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($op->name =~ /gvsv/) { } 0 7 7
elsif ($op->name eq 'nextstate') { } 1 6 7
11 0 my $var = '$'.$op->sv->SAFENAME;
12 0 my $top = $op;
13 0 ▶ $top = $top->sibling while $top->can("sibling") and ${$top->sibling};
Branch: 1 branch
BranchTrueFalseTotal
$top->can("sibling") and ${$top->sibling;} and do { $top = $top->sibling } 0 0 0
Condition0%0/3
$top->can("sibling") and ${$top->sibling;}
!ll&&!rl&&r
000
MC/DC0%0/2
$top->can("sibling") and ${$top->sibling;}
$top->can("sibling") ${$top->sibling;}
Truth table0%0/3
A and B
A= $top->can("sibling")B= ${$top->sibling;}
ABresult
0X0
100
111
14 0 ▶ if ($top->next->name =~ /assign/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($top->next->name =~ /assign/) { } 0 0 0
elsif (not exists $assigned{$var}) { } 0 0 0
15 0 $assigned{$var}++;
16 } elsif (not exists $assigned{$var}) {
17 0 warn "$var may be used uninitialized at $prog line $line.\n";
18 }
19 } elsif ($op->name eq "nextstate") {
20 1 $prog = $op->file; $line = $op->line;
21 }
22 }
23 }
24  
25 =pod
26  
27 =head1 NAME
28  
29 uninit - Warn about uninitialized variables
30  
31 =head1 SYNOPSIS
32  
33 perl -Muninit myprogram
34  
35 =head1 DESCRIPTION
36  
37 It's all very well being warned about the use of C<undef> if you
38 don't know what variable it is that contains C<undef>, especially
39 if you've got more than one variable in a line.
40  
41 C<uninit> attempts to do compile-time static checking of your
42 program to see if any variables are used before they have any
43 values assigned to them; it also reports B<which> variable actually
44 caused the problem.
45  
46 It isn't guaranteed to catch all cases, and you can probably trick
47 it with judicious use of C<eval>, but I can't do anything about that.
48 It's only a guideline.
49  
50 =head1 AUTHOR
51  
52 Simon Cozens, C<simon@cpan.org>
53  
54 =head1 SEE ALSO
55  
56 L<optimize>, L<B>
57  
58 =cut
59  
60 1 1;
↑ Summary