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   97072 use strict;
  133         243  
  133         5319  
3 133     133   604 use warnings;
  133         188  
  133         3612  
4 133     133   1007 use Perl::Lint::Constants::Type;
  133         192  
  133         83305  
5 133     133   947 use parent "Perl::Lint::Policy";
  133         219  
  133         858  
6              
7             use constant {
8 133         28914 DESC => 'Private variable used',
9             EXPL => 'Use published APIs',
10 133     133   9172 };
  133         220  
11              
12             sub evaluate {
13 3     3 0 6 my ($class, $file, $tokens, $src, $args) = @_;
14              
15 3         3 my @violations;
16 3         13 for (my $i = 0, my $token_type, my $token_data; my $token = $tokens->[$i]; $i++) {
17 87         72 $token_type = $token->{type};
18 87         65 $token_data = $token->{data};
19              
20 87 100 100     252 if ($token_type == NAMESPACE && $token_data =~ /\A_/) {
21 11         41 push @violations, {
22             filename => $file,
23             line => $token->{line},
24             description => DESC,
25             explanation => EXPL,
26             policy => __PACKAGE__,
27             };
28             }
29             }
30              
31 3         11 return \@violations;
32             }
33              
34             1;
35