« Perl/Lint/Policy/TestingAndDebugging/RequireUseWarnings.pm
↑ Summary
Perl/Lint/Policy/InputOutput/ProhibitOneArgSelect.pm »
| 1 | package Perl::Lint::Policy::ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions; | ||||||||||||||||||||||||||||
| 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 => 'Found "%s" in condition for an "%s"', | |||||||||||||||||||||||||||
| 9 | EXPL => [99], | ||||||||||||||||||||||||||||
| 10 | 2 | }; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | my %invalid_op_types = ( | |||||||||||||||||||||||||||
| 13 | &NOT => '!', | ||||||||||||||||||||||||||||
| 14 | &ALPHABET_NOT => 'not', | ||||||||||||||||||||||||||||
| 15 | &STRING_NOT_EQUAL => 'ne', | ||||||||||||||||||||||||||||
| 16 | &NOT_EQUAL => '!=', | ||||||||||||||||||||||||||||
| 17 | &LESS => '<', | ||||||||||||||||||||||||||||
| 18 | &LESS_EQUAL => '<=', | ||||||||||||||||||||||||||||
| 19 | &GREATER => '>', | ||||||||||||||||||||||||||||
| 20 | &GREATER_EQUAL => '>=', | ||||||||||||||||||||||||||||
| 21 | &COMPARE => '<=>', | ||||||||||||||||||||||||||||
| 22 | &STRING_LESS => 'lt', | ||||||||||||||||||||||||||||
| 23 | &STRING_GREATER => 'gt', | ||||||||||||||||||||||||||||
| 24 | &STRING_LESS_EQUAL => 'le', | ||||||||||||||||||||||||||||
| 25 | &STRING_GREATER_EQUAL => 'ge', | ||||||||||||||||||||||||||||
| 26 | &STRING_COMPARE => 'cmp', | ||||||||||||||||||||||||||||
| 27 | ®_NOT => '!~', | ||||||||||||||||||||||||||||
| 28 | &STRING_NOT_EQUAL => 'ne', | ||||||||||||||||||||||||||||
| 29 | &NOT_EQUAL => '!=', | ||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub evaluate { | ||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 0 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | my @violations; | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | for (my $i = 0, my $token_type; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ($token_type == UNLESS_STATEMENT || $token_type == UNTIL_STATEMENT) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token_type == 99 or $token_type == 100
MC/DC0%0/2
$token_type == 99 or $token_type == 100
$token_type == 99
$token_type == 100
Truth table0%0/3
A or B
A= $token_type == 99B= $token_type == 100
| |||||||||||||||||||||||||||||
| 39 | 0 | my $control_structure = $token->{data}; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | $token = $tokens->[++$i] or last; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ($token->{type} != LEFT_PAREN) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | for (; $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 45 | 0 | ▶ | if ($token_type == SEMI_COLON) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 46 | 0 | last; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | elsif ($invalid_op_types{$token_type}) { | ||||||||||||||||||||||||||||
| 49 | push @violations, { | ||||||||||||||||||||||||||||
| 50 | filename => $file, | ||||||||||||||||||||||||||||
| 51 | line => $token->{line}, | ||||||||||||||||||||||||||||
| 52 | 0 | description => sprintf(DESC, $invalid_op_types{$token_type}, $control_structure), | |||||||||||||||||||||||||||
| 53 | explanation => EXPL, | ||||||||||||||||||||||||||||
| 54 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||
| 55 | }; | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | next; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | my $lpnum = 1; | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | for ($i++; $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 67 | 0 | $lpnum++; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | elsif ($token_type == RIGHT_PAREN) { | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | last if --$lpnum <= 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | elsif ($invalid_op_types{$token_type}) { | ||||||||||||||||||||||||||||
| 73 | push @violations, { | ||||||||||||||||||||||||||||
| 74 | filename => $file, | ||||||||||||||||||||||||||||
| 75 | line => $token->{line}, | ||||||||||||||||||||||||||||
| 76 | 0 | description => sprintf(DESC, $invalid_op_types{$token_type}, $control_structure), | |||||||||||||||||||||||||||
| 77 | explanation => EXPL, | ||||||||||||||||||||||||||||
| 78 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||
| 79 | }; | ||||||||||||||||||||||||||||
| 80 | 0 | last; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | return \@violations; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 2 | 1; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||