« Perl/Lint/Policy/Miscellanea/ProhibitFormats.pm
↑ Summary
Perl/Lint/Policy/ValuesAndExpressions/ProhibitEscapedCharacters.pm »
| 1 | package Perl::Lint::Policy::ControlStructures::ProhibitCStyleForLoops; | ||||||||||||||||||||||||||||
| 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 Perl::Lint::Constants::Kind; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use parent "Perl::Lint::Policy"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use constant { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | DESC => 'C-style "for" loop used', | |||||||||||||||||||||||||||
| 10 | EXPL => [100], | ||||||||||||||||||||||||||||
| 11 | 3 | }; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | sub evaluate { | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=11 SCAR=24.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 2 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | my @violations; | |||||||||||||||||||||||||||
| 17 | 2 | ▶ | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 38 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 38 | ▶ | if ($token_type == FOR_STATEMENT || $token_type == FOREACH_STATEMENT) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$token_type == 133 or $token_type == 134
MC/DC50%1/2
$token_type == 133 or $token_type == 134
$token_type == 133
$token_type == 134
Truth table66%2/3
A or B
A= $token_type == 133B= $token_type == 134
| |||||||||||||||||||||||||||||
| 21 | 1 | my $token = $tokens->[++$i]; | |||||||||||||||||||||||||||
| 22 | 1 | ▶ | if ($token->{type} == LEFT_PAREN) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 1 | my $semi_colon_count = 0; | |||||||||||||||||||||||||||
| 24 | 1 | my $left_paren_num = 1; | |||||||||||||||||||||||||||
| 25 | 1 | ▶ | for ($i++; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 12 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 27 | 12 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 28 | 0 | $left_paren_num++; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | elsif ($token_type == RIGHT_PAREN) { | ||||||||||||||||||||||||||||
| 31 | 1 | ▶ | last if --$left_paren_num <= 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | elsif ($token_type == SEMI_COLON) { | ||||||||||||||||||||||||||||
| 34 | 2 | $semi_colon_count++; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 1 | ▶ | if ($semi_colon_count == 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | push @violations, { | ||||||||||||||||||||||||||||
| 40 | filename => $file, | ||||||||||||||||||||||||||||
| 41 | line => $token->{line}, | ||||||||||||||||||||||||||||
| 42 | 1 | description => DESC, | |||||||||||||||||||||||||||
| 43 | explanation => EXPL, | ||||||||||||||||||||||||||||
| 44 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||
| 45 | }; | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 2 | return \@violations; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 3 | 1; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||