« Perl/Lint/Policy/RegularExpressions/ProhibitComplexRegexes.pm
↑ Summary
Perl/Lint/Policy/Variables/ProhibitLocalVars.pm »
| 1 | package Perl::Lint::Policy::InputOutput::ProhibitReadlineInForLoop; | ||||||||||||||||||||||||||||
| 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 => 'Readline inside "for" loop', | |||||||||||||||||||||||||||
| 9 | EXPL => [211], | ||||||||||||||||||||||||||||
| 10 | 2 | }; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub evaluate { | ||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 0 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | my @violations; | |||||||||||||||||||||||||||
| 16 | 0 | ▶ | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 0 | ▶ | if ($token_type == FOR_STATEMENT || $token_type == FOREACH_STATEMENT) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token_type == 133 or $token_type == 134
MC/DC0%0/2
$token_type == 133 or $token_type == 134
$token_type == 133
$token_type == 134
Truth table0%0/3
A or B
A= $token_type == 133B= $token_type == 134
| |||||||||||||||||||||||||||||
| 20 | 0 | $i++; | |||||||||||||||||||||||||||
| 21 | 0 | $token = $tokens->[$i]; | |||||||||||||||||||||||||||
| 22 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 23 | 0 | ▶ | if ($token_type == DIAMOND || $token_type == LESS) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token_type == 32 or $token_type == 8
MC/DC0%0/2
$token_type == 32 or $token_type == 8
$token_type == 32
$token_type == 8
Truth table0%0/3
A or B
A= $token_type == 32B= $token_type == 8
| |||||||||||||||||||||||||||||
| 24 | # ~~~~ XXX should be HandleDecl in fact | ||||||||||||||||||||||||||||
| 25 | push @violations, { | ||||||||||||||||||||||||||||
| 26 | filename => $file, | ||||||||||||||||||||||||||||
| 27 | line => $token->{line}, | ||||||||||||||||||||||||||||
| 28 | 0 | description => DESC, | |||||||||||||||||||||||||||
| 29 | explanation => EXPL, | ||||||||||||||||||||||||||||
| 30 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||
| 31 | }; | ||||||||||||||||||||||||||||
| 32 | 0 | next; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | for (; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 37 | 0 | my $left_paren_num = 0; | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | $left_paren_num++; | |||||||||||||||||||||||||||
| 40 | 0 | ▶ | for ($i++; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 43 | 0 | $left_paren_num++; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | elsif ($token_type == RIGHT_PAREN) { | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | last if --$left_paren_num <= 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | elsif ($token_type == DIAMOND) { | ||||||||||||||||||||||||||||
| 49 | push @violations, { | ||||||||||||||||||||||||||||
| 50 | filename => $file, | ||||||||||||||||||||||||||||
| 51 | line => $token->{line}, | ||||||||||||||||||||||||||||
| 52 | 0 | description => DESC, | |||||||||||||||||||||||||||
| 53 | explanation => EXPL, | ||||||||||||||||||||||||||||
| 54 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||
| 55 | }; | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | elsif ($token_type == HANDLE_DELIM) { | ||||||||||||||||||||||||||||
| 58 | 0 | ▶ | for ($i++; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ($token_type == HANDLE_DELIM) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | push @violations, { | ||||||||||||||||||||||||||||
| 62 | filename => $file, | ||||||||||||||||||||||||||||
| 63 | line => $token->{line}, | ||||||||||||||||||||||||||||
| 64 | 0 | description => DESC, | |||||||||||||||||||||||||||
| 65 | explanation => EXPL, | ||||||||||||||||||||||||||||
| 66 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||
| 67 | }; | ||||||||||||||||||||||||||||
| 68 | 0 | last; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | 0 | last; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | return \@violations; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 2 | 1; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||