« Perl/Lint/Policy/InputOutput/ProhibitOneArgSelect.pm
↑ Summary
Perl/Lint/Policy/Modules/RequireEndWithOne.pm »
| 1 | package Perl::Lint::Policy::BuiltinFunctions::ProhibitLvalueSubstr; | ||||||||||||||||||||||||||||||||
| 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 => 'Lvalue form of "substr" used', | |||||||||||||||||||||||||||||||
| 9 | EXPL => [165], | ||||||||||||||||||||||||||||||||
| 10 | 2 | }; | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=13 SCAR=52.0
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 'substr') { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$token_type == 70 and $token_data eq "substr"
MC/DC0%0/2
$token_type == 70 and $token_data eq "substr"
$token_type == 70
$token_data eq "substr"
Truth table0%0/3
A and B
A= $token_type == 70B= $token_data eq "substr"
| |||||||||||||||||||||||||||||||||
| 21 | 0 | $token = $tokens->[++$i]; | |||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | if ($token->{type} == LEFT_PAREN) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 23 | 0 | my $left_paren_num = 1; | |||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | for ($i++; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 25 | 0 | $token = $tokens->[++$i]; | |||||||||||||||||||||||||||||||
| 26 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 29 | 0 | $left_paren_num++; | |||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||
| 31 | elsif ($token_type == RIGHT_PAREN) { | ||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if (--$left_paren_num <= 0) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 33 | 0 | my $next_token = $tokens->[++$i]; | |||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ($next_token->{type} == ASSIGN) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 35 | push @violations, { | ||||||||||||||||||||||||||||||||
| 36 | filename => $file, | ||||||||||||||||||||||||||||||||
| 37 | line => $token->{line}, | ||||||||||||||||||||||||||||||||
| 38 | 0 | description => DESC, | |||||||||||||||||||||||||||||||
| 39 | explanation => EXPL, | ||||||||||||||||||||||||||||||||
| 40 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||
| 41 | }; | ||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||
| 43 | 0 | last; | |||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||
| 49 | elsif ($token_type == USE_DECL) { | ||||||||||||||||||||||||||||||||
| 50 | 0 | $token = $tokens->[++$i]; | |||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ($token->{type} == DOUBLE) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 52 | 0 | ($token_data = $token->{data}) =~ s/_//g; | |||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($token_data <= 5.004) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 54 | 0 | return []; | |||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 0 | return \@violations; | |||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | 2 | 1; | |||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||