Perl/Lint/Policy/Variables/RequireInitializationForLocalVars.pm

filter: Statementstmt 45.7% 16 / 35 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 36.2% 21 / 58 CC 9 SCAR 40.6
CC
9
Cov
31%
evaluate
90.0
BEGIN
1.0
BEGIN
1.0
CRAP 58.2
« Perl/Lint/Policy/RegularExpressions/ProhibitUnusualDelimiters.pm ↑ Summary Perl/Lint/Policy/Subroutines/ProhibitNestedSubs.pm »
1 package Perl::Lint::Policy::Variables::RequireInitializationForLocalVars;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Perl::Lint::Constants::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use parent "Perl::Lint::Policy";
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 DESC => '"local" variable not initialized',
9 EXPL => [78],
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=9 SCAR=45.0
Pod undocumented
13 0 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 0 my @violations;
16 0 ▶ for (my $i = 0, my $token_type; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
17 0 $token_type = $token->{type};
18  
19 0 ▶ if ($token_type == LOCAL_DECL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 90) 0 0 0
20 0 $token = $tokens->[++$i];
21 0 $token_type = $token->{type};
22  
23 0 ▶ if ($token_type == LEFT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 107) 0 0 0
24 0 my $left_paren_num = 1;
25 0 ▶ for ($i++; $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $tokens->[$i]) 0 0 0
26 0 $token_type = $token->{type};
27  
28 0 ▶ if ($token_type == LEFT_PAREN) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 107) { } 0 0 0
elsif ($token_type == 108) { } 0 0 0
29 0 $left_paren_num++;
30 }
31 elsif ($token_type == RIGHT_PAREN) {
32 0 ▶ last if --$left_paren_num <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if --$left_paren_num <= 0 0 0 0
33 }
34 }
35 }
36  
37 0 $token = $tokens->[++$i];
38 0 $token_type = $token->{type};
39  
40 0 ▶ if ($token_type != ASSIGN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type != 65) 0 0 0
41 push @violations, {
42 filename => $file,
43 line => $token->{line},
44 0 description => DESC,
45 explanation => EXPL,
46 policy => __PACKAGE__,
47 };
48 }
49 }
50 }
51  
52 0 return \@violations;
53 }
54  
55 2 1;
56  
« Perl/Lint/Policy/RegularExpressions/ProhibitUnusualDelimiters.pm ↑ Summary Perl/Lint/Policy/Subroutines/ProhibitNestedSubs.pm »