« blib/lib/Perl/Lint/Policy/Miscellanea/ProhibitUselessNoLint.pm
↑ Summary
blib/lib/Perl/Lint/Policy/Modules/ProhibitConditionalUseStatements.pm »
| 1 | package Perl::Lint::Policy::Modules::ProhibitAutomaticExportation; | ||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Perl::Lint::Constants::Type; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 5 | use parent "Perl::Lint::Policy"; | ||
| 6 | |||
| 7 | use constant { | ||
| 8 | DESC => 'Symbols are exported by default', | ||
| 9 | EXPL => 'Use "@EXPORT_OK" or "%EXPORT_TAGS" instead', | ||
| 10 | }; | ||
| 11 | |||
| 12 | sub evaluate { | ||
| 13 | my ($class, $file, $tokens, $args) = @_; | ||
| 14 | |||
| 15 | my @violations; | ||
| 16 | for (my $i = 0, my $next_token, my $token_type, my $token_data; my $token = $tokens->[$i]; $i++) { | ||
| 17 | $next_token = $tokens->[$i+1]; | ||
| 18 | $token_type = $token->{type}; | ||
| 19 | $token_data = $token->{data}; | ||
| 20 | if ( | ||
| 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 | description => DESC, | ||
| 28 | explanation => EXPL, | ||
| 29 | policy => __PACKAGE__, | ||
| 30 | }; | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | return \@violations; | ||
| 35 | } | ||
| 36 | |||
| 37 | 1; | ||
| 38 | |||