« Perl/Lint/Policy/ValuesAndExpressions/RequireInterpolationOfMetachars.pm
↑ Summary
Perl/Lint/Policy/Modules/RequireBarewordIncludes.pm »
| 1 | package Perl::Lint::Policy::BuiltinFunctions::RequireSimpleSortBlock; | ||||||||||||||||||||||||||||
| 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 => 'Sort blocks should have a single statement', | |||||||||||||||||||||||||||
| 9 | EXPL => [149], | ||||||||||||||||||||||||||||
| 10 | 2 | }; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub evaluate { | ||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=11 SCAR=48.8
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 | 0 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | if ($token_type == BUILTIN_FUNC && $token_data eq 'sort') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/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 table0%0/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 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ($token_type != LEFT_BRACE) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 0 | next; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | my $left_brace_num = 1; | |||||||||||||||||||||||||||
| 33 | 0 | my $concat_stmt = ''; # XXX | |||||||||||||||||||||||||||
| 34 | 0 | ▶ | for ($i++; $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ($token_type == LEFT_BRACE) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 38 | 0 | $left_brace_num++; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | elsif ($token_type == RIGHT_BRACE) { | ||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if (--$left_brace_num <= 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if (scalar(@_ = split /;/, $concat_stmt) > 1) { # XXX | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | push @violations, { | ||||||||||||||||||||||||||||
| 44 | filename => $file, | ||||||||||||||||||||||||||||
| 45 | line => $token->{line}, | ||||||||||||||||||||||||||||
| 46 | 0 | description => DESC, | |||||||||||||||||||||||||||
| 47 | explanation => EXPL, | ||||||||||||||||||||||||||||
| 48 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||
| 49 | }; | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | 0 | last; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | else { | ||||||||||||||||||||||||||||
| 55 | 0 | $concat_stmt .= $token->{data}; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | return \@violations; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 2 | 1; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||