File Coverage

blib/lib/Perl/Lint/Policy/Variables/ProtectPrivateVars.pm
Criterion Covered Total %
statement 23 23 100.0
branch 2 2 100.0
condition 3 3 100.0
subroutine 6 6 100.0
pod 0 1 0.0
total 34 35 97.1


line stmt bran cond sub pod time code
1             package Perl::Lint::Policy::Variables::ProtectPrivateVars;
2 133     133   68840 use strict;
  133         163  
  133         3220  
3 133     133   418 use warnings;
  133         150  
  133         2552  
4 133     133   805 use Perl::Lint::Constants::Type;
  133         139  
  133         59139  
5 133     133   546 use parent "Perl::Lint::Policy";
  133         160  
  133         574  
6              
7             use constant {
8 133         22046 DESC => 'Private variable used',
9             EXPL => 'Use published APIs',
10 133     133   6404 };
  133         176  
11              
12             sub evaluate {
13 3     3 0 5 my ($class, $file, $tokens, $src, $args) = @_;
14              
15 3         3 my @violations;
16 3         11 for (my $i = 0, my $token_type, my $token_data; my $token = $tokens->[$i]; $i++) {
17 87         57 $token_type = $token->{type};
18 87         69 $token_data = $token->{data};
19              
20 87 100 100     198 if ($token_type == NAMESPACE && $token_data =~ /\A_/) {
21             push @violations, {
22             filename => $file,
23             line => $token->{line},
24 11         35 description => DESC,
25             explanation => EXPL,
26             policy => __PACKAGE__,
27             };
28             }
29             }
30              
31 3         10 return \@violations;
32             }
33              
34             1;
35