File Coverage

blib/lib/Perl/Lint/Policy/Modules/ProhibitAutomaticExportation.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 2 100.0
condition 11 12 91.6
subroutine 6 6 100.0
pod 0 1 0.0
total 43 45 95.5


line stmt bran cond sub pod time code
1             package Perl::Lint::Policy::Modules::ProhibitAutomaticExportation;
2 133     133   91264 use strict;
  133         269  
  133         5072  
3 133     133   616 use warnings;
  133         219  
  133         3485  
4 133     133   1147 use Perl::Lint::Constants::Type;
  133         205  
  133         81169  
5 133     133   876 use parent "Perl::Lint::Policy";
  133         230  
  133         792  
6              
7             use constant {
8 133         29115 DESC => 'Symbols are exported by default',
9             EXPL => 'Use "@EXPORT_OK" or "%EXPORT_TAGS" instead',
10 133     133   8703 };
  133         248  
11              
12             sub evaluate {
13 11     11 0 27 my ($class, $file, $tokens, $args) = @_;
14              
15 11         10 my @violations;
16 11         42 for (my $i = 0, my $next_token, my $token_type, my $token_data; my $token = $tokens->[$i]; $i++) {
17 143         179 $next_token = $tokens->[$i+1];
18 143         132 $token_type = $token->{type};
19 143         131 $token_data = $token->{data};
20 143 100 100     814 if (
      100        
      100        
      66        
21             ($token_type == GLOBAL_ARRAY_VAR && $token_data eq '@EXPORT') ||
22             ($token_type == NAMESPACE && $token_data eq 'EXPORT' && $next_token->{type} == ASSIGN)
23             ) {
24 4         27 push @violations, {
25             filename => $file,
26             line => $token->{line},
27             description => DESC,
28             explanation => EXPL,
29             policy => __PACKAGE__,
30             };
31             }
32             }
33              
34 11         56 return \@violations;
35             }
36              
37             1;
38