« Perl/Lint/Policy/Variables/RequireInitializationForLocalVars.pm
↑ Summary
Perl/Lint/Policy/InputOutput/RequireBracedFileHandleWithPrint.pm »
| 1 | package Perl::Lint::Policy::Subroutines::ProhibitNestedSubs; | ||||||||||||||||||
| 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 | # TODO msg! | ||||||||||||||||||
| 8 | 2 | ▶ | use constant { | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | 2 | DESC => 'Nested named subroutine', | |||||||||||||||||
| 10 | EXPL => 'Declaring a named sub inside another named sub does not prevent the ' | ||||||||||||||||||
| 11 | . 'inner sub from being global', | ||||||||||||||||||
| 12 | 2 | }; | |||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | 0 | ▶ | sub evaluate { | ||||||||||||||||
|
Subroutine
evaluate: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||
| 15 | 0 | my ($class, $file, $tokens, $args) = @_; | |||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | 0 | my @violations; | |||||||||||||||||
| 18 | 0 | ▶ | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 19 | 0 | my $token_type = $token->{type}; | |||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | 0 | ▶ | if ($token_type == FUNCTION) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 22 | 0 | my $left_brace_num = 0; | |||||||||||||||||
| 23 | 0 | ▶ | for ($i++; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 24 | 0 | my $token_type = $token->{type}; | |||||||||||||||||
| 25 | 0 | ▶ | if ($token_type == FUNCTION) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 26 | 0 | ▶ | if ($left_brace_num > 0) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 27 | push @violations, { | ||||||||||||||||||
| 28 | filename => $file, | ||||||||||||||||||
| 29 | line => $token->{line}, | ||||||||||||||||||
| 30 | 0 | description => DESC, | |||||||||||||||||
| 31 | explanation => EXPL, | ||||||||||||||||||
| 32 | policy => __PACKAGE__, | ||||||||||||||||||
| 33 | }; | ||||||||||||||||||
| 34 | } | ||||||||||||||||||
| 35 | } | ||||||||||||||||||
| 36 | elsif ($token_type == LEFT_BRACE) { | ||||||||||||||||||
| 37 | 0 | $left_brace_num++; | |||||||||||||||||
| 38 | } | ||||||||||||||||||
| 39 | elsif ($token_type == RIGHT_BRACE) { | ||||||||||||||||||
| 40 | 0 | $left_brace_num--; | |||||||||||||||||
| 41 | 0 | ▶ | last if $left_brace_num <= 0; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 42 | } | ||||||||||||||||||
| 43 | } | ||||||||||||||||||
| 44 | } | ||||||||||||||||||
| 45 | } | ||||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | 0 | return \@violations; | |||||||||||||||||
| 48 | } | ||||||||||||||||||
| 49 | |||||||||||||||||||
| 50 | 2 | 1; | |||||||||||||||||
| 51 | |||||||||||||||||||