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   66534 use strict;
  133         157  
  133         3068  
3 133     133   422 use warnings;
  133         149  
  133         2352  
4 133     133   779 use Perl::Lint::Constants::Type;
  133         138  
  133         59190  
5 133     133   559 use parent "Perl::Lint::Policy";
  133         186  
  133         517  
6              
7             use constant {
8 133         22676 DESC => 'Symbols are exported by default',
9             EXPL => 'Use "@EXPORT_OK" or "%EXPORT_TAGS" instead',
10 133     133   6421 };
  133         169  
11              
12             sub evaluate {
13 11     11 0 13 my ($class, $file, $tokens, $args) = @_;
14              
15 11         11 my @violations;
16 11         29 for (my $i = 0, my $next_token, my $token_type, my $token_data; my $token = $tokens->[$i]; $i++) {
17 143         110 $next_token = $tokens->[$i+1];
18 143         92 $token_type = $token->{type};
19 143         107 $token_data = $token->{data};
20 143 100 100     520 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             push @violations, {
25             filename => $file,
26             line => $token->{line},
27 4         23 description => DESC,
28             explanation => EXPL,
29             policy => __PACKAGE__,
30             };
31             }
32             }
33              
34 11         34 return \@violations;
35             }
36              
37             1;
38