File Coverage

blib/lib/uninit.pm
Criterion Covered Total %
statement 9 16 56.2
branch 3 8 37.5
condition 0 3 0.0
subroutine 2 2 100.0
pod n/a
total 14 29 48.2


line stmt bran cond sub pod time code
1             package uninit;
2              
3             $uninit::VERSION="1.00";
4              
5             CHECK {
6 1     1   5955 use B qw(main_start);
  1         2  
  1         293  
7 1     1   603 my %globs;
8 1         1 my ($prog, $line);
9 1         22 for (my $op = main_start; $$op; $op = $op->next) {
10 7 50       1131 if ($op->name =~ /gvsv/) {
    100          
11 0         0 my $var = '$'.$op->sv->SAFENAME;
12 0         0 my $top = $op;
13 0   0     0 $top = $top->sibling while $top->can("sibling") and ${$top->sibling};
  0         0  
14 0 0       0 if ($top->next->name =~ /assign/) {
    0          
15 0         0 $assigned{$var}++;
16             } elsif (not exists $assigned{$var}) {
17 0         0 warn "$var may be used uninitialized at $prog line $line.\n";
18             }
19             } elsif ($op->name eq "nextstate") {
20 1         4 $prog = $op->file; $line = $op->line;
  1         17  
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 if you
38             don't know what variable it is that contains C, especially
39             if you've got more than one variable in a line.
40              
41             C 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 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, but I can't do anything about that.
48             It's only a guideline.
49              
50             =head1 AUTHOR
51              
52             Simon Cozens, C
53              
54             =head1 SEE ALSO
55              
56             L, L
57              
58             =cut
59              
60             1;