« Perl/Lint/Policy/ControlStructures/ProhibitUnlessBlocks.pm
↑ Summary
Perl/Lint/Policy/BuiltinFunctions/RequireBlockGrep.pm »
| 1 | package Perl::Lint::Policy::ControlStructures::ProhibitUntilBlocks; | ||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 3 | ▶ | use Perl::Lint::Constants::Type; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 3 | ▶ | use parent "Perl::Lint::Policy"; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 3 | ▶ | use constant { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 3 | DESC => '"until" block used', | |||||||||||||
| 9 | EXPL => [97], | ||||||||||||||
| 10 | 3 | }; | |||||||||||||
| 11 | |||||||||||||||
| 12 | 2 | ▶ | sub evaluate { | ||||||||||||
|
Subroutine
evaluate: called CC=9 SCAR=36.4
Pod
undocumented
| |||||||||||||||
| 13 | 2 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||
| 14 | |||||||||||||||
| 15 | 2 | my @violations; | |||||||||||||
| 16 | 2 | ▶ | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 17 | 51 | my $token_type = $token->{type}; | |||||||||||||
| 18 | |||||||||||||||
| 19 | 51 | ▶ | if ($token_type == UNTIL_STATEMENT) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 20 | 0 | ▶ | if ($tokens->[++$i]->{type} == LEFT_PAREN) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 21 | 0 | my $left_paren_num = 1; | |||||||||||||
| 22 | 0 | ▶ | for ($i++; my $token = $tokens->[$i]; $i++) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 23 | 0 | my $token_type = $token->{type}; | |||||||||||||
| 24 | 0 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 25 | 0 | $left_paren_num++; | |||||||||||||
| 26 | } | ||||||||||||||
| 27 | elsif ($token_type == RIGHT_PAREN) { | ||||||||||||||
| 28 | 0 | ▶ | last if --$left_paren_num <= 0; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 29 | } | ||||||||||||||
| 30 | } | ||||||||||||||
| 31 | 0 | ▶ | if ($tokens->[++$i]->{type} == LEFT_BRACE) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 32 | push @violations, { | ||||||||||||||
| 33 | filename => $file, | ||||||||||||||
| 34 | line => $token->{line}, | ||||||||||||||
| 35 | 0 | description => DESC, | |||||||||||||
| 36 | explanation => EXPL, | ||||||||||||||
| 37 | policy => __PACKAGE__, | ||||||||||||||
| 38 | }; | ||||||||||||||
| 39 | } | ||||||||||||||
| 40 | } | ||||||||||||||
| 41 | } | ||||||||||||||
| 42 | } | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 2 | return \@violations; | |||||||||||||
| 45 | } | ||||||||||||||
| 46 | |||||||||||||||
| 47 | 3 | 1; | |||||||||||||
| 48 | |||||||||||||||