« Perl/Lint/Policy/BuiltinFunctions/ProhibitUselessTopic.pm
↑ Summary
Perl/Lint/Policy/RegularExpressions/ProhibitEnumeratedClasses.pm »
| 1 | package Perl::Lint::Policy::BuiltinFunctions::ProhibitReverseSortBlock; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 => 'Forbid $b before $a in sort blocks', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | EXPL => [152], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=19 SCAR=53.7
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 | 51 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 51 | ▶ | if ($token_type == BUILTIN_FUNC && $token_data eq 'sort') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$token_type == 70 and $token_data eq "sort"
MC/DC0%0/2
$token_type == 70 and $token_data eq "sort"
$token_type == 70
$token_data eq "sort"
Truth table66%2/3
A and B
A= $token_type == 70B= $token_data eq "sort"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | $token = $tokens->[++$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | if ($token->{type} == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $token = $tokens->[++$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | if ($token->{type} == LEFT_BRACE) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $left_brace_num = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $is_b_at_before_comparator = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | for ($i++; $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ($token_type == COMPARE || $token_type == STRING_COMPARE) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition0%0/3
$token_type == 33 or $token_type == 44
MC/DC0%0/2
$token_type == 33 or $token_type == 44
$token_type == 33
$token_type == 44
Truth table0%0/3
A or B
A= $token_type == 33B= $token_type == 44
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if ($is_b_at_before_comparator) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | push @violations, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | filename => $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | description => DESC, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | explanation => EXPL, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | elsif ($token_type == LEFT_BRACE) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $left_brace_num++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | elsif ($token_type == RIGHT_BRACE) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | last if --$left_brace_num <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ▶ | elsif ($token_type == VAR && $token_data eq '$b') { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$token_type == 166 and $token_data eq "\$b"
MC/DC0%0/2
$token_type == 166 and $token_data eq "\$b"
$token_type == 166
$token_data eq "\$b"
Truth table0%0/3
A and B
A= $token_type == 166B= $token_data eq "\$b"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $is_b_at_before_comparator = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ▶ | elsif ( # XXX enough? | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$token_type == 53 or $token_type == 52 or $token_type == 14 or $token_type == 16
$token_type == 53 or $token_type == 52 or $token_type == 14
$token_type == 53 or $token_type == 52
MC/DC0%0/4
$token_type == 53 or $token_type == 52 or $token_type == 14 or $token_type == 16
$token_type == 53
$token_type == 52
$token_type == 14
$token_type == 16
Truth table0%0/5
A or B or C or D
A= $token_type == 53B= $token_type == 52C= $token_type == 14D= $token_type == 16
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | $token_type == OR || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | $token_type == AND || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | $token_type == ALPHABET_OR || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | $token_type == ALPHABET_AND | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $is_b_at_before_comparator = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | return \@violations; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||