« Perl/Lint/Policy/InputOutput/ProhibitInteractiveTest.pm
↑ Summary
Perl/Lint/Policy/Variables/ProtectPrivateVars.pm »
| 1 | package Perl::Lint::Policy::Modules::ProhibitMultiplePackages; | ||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use Perl::Lint::Constants::Type; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use parent "Perl::Lint::Policy"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use constant { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | DESC => 'Multiple "package" declarations', | |||||||||
| 9 | EXPL => 'Limit to one per file', | ||||||||||
| 10 | 2 | }; | |||||||||
| 11 | |||||||||||
| 12 | 0 | ▶ | sub evaluate { | ||||||||
|
Subroutine
evaluate: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 13 | 0 | my ($class, $file, $tokens, $args) = @_; | |||||||||
| 14 | |||||||||||
| 15 | 0 | my @violations; | |||||||||
| 16 | 0 | my $had_declared_package = 0; | |||||||||
| 17 | 0 | ▶ | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | 0 | my $token_type = $token->{type}; | |||||||||
| 19 | 0 | ▶ | if ($token_type == PACKAGE) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | ▶ | unless ($had_declared_package) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 0 | $had_declared_package = 1; | |||||||||
| 22 | 0 | next; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | push @violations, { | ||||||||||
| 26 | filename => $file, | ||||||||||
| 27 | line => $token->{line}, | ||||||||||
| 28 | 0 | description => DESC, | |||||||||
| 29 | explanation => EXPL, | ||||||||||
| 30 | policy => __PACKAGE__, | ||||||||||
| 31 | }; | ||||||||||
| 32 | } | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | return \@violations; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 2 | 1; | |||||||||
| 39 | |||||||||||