| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::BuiltinFunctions::ProhibitLvalueSubstr; |
|
2
|
133
|
|
|
133
|
|
68810
|
use strict; |
|
|
133
|
|
|
|
|
184
|
|
|
|
133
|
|
|
|
|
3131
|
|
|
3
|
133
|
|
|
133
|
|
414
|
use warnings; |
|
|
133
|
|
|
|
|
176
|
|
|
|
133
|
|
|
|
|
2509
|
|
|
4
|
133
|
|
|
133
|
|
880
|
use Perl::Lint::Constants::Type; |
|
|
133
|
|
|
|
|
172
|
|
|
|
133
|
|
|
|
|
58960
|
|
|
5
|
133
|
|
|
133
|
|
578
|
use parent "Perl::Lint::Policy"; |
|
|
133
|
|
|
|
|
232
|
|
|
|
133
|
|
|
|
|
598
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
|
8
|
133
|
|
|
|
|
35488
|
DESC => 'Lvalue form of "substr" used', |
|
9
|
|
|
|
|
|
|
EXPL => [165], |
|
10
|
133
|
|
|
133
|
|
6506
|
}; |
|
|
133
|
|
|
|
|
185
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
|
13
|
8
|
|
|
8
|
0
|
16
|
my ($class, $file, $tokens, $src, $args) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
8
|
|
|
|
|
6
|
my @violations; |
|
16
|
8
|
|
|
|
|
25
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
|
17
|
56
|
|
|
|
|
39
|
my $token_type = $token->{type}; |
|
18
|
56
|
|
|
|
|
42
|
my $token_data = $token->{data}; |
|
19
|
|
|
|
|
|
|
|
|
20
|
56
|
100
|
66
|
|
|
170
|
if ($token_type == BUILTIN_FUNC && $token_data eq 'substr') { |
|
|
|
100
|
|
|
|
|
|
|
21
|
10
|
|
|
|
|
12
|
$token = $tokens->[++$i]; |
|
22
|
10
|
100
|
|
|
|
21
|
if ($token->{type} == LEFT_PAREN) { |
|
23
|
8
|
|
|
|
|
7
|
my $left_paren_num = 1; |
|
24
|
8
|
|
|
|
|
13
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
|
25
|
24
|
|
|
|
|
21
|
$token = $tokens->[++$i]; |
|
26
|
24
|
|
|
|
|
18
|
$token_type = $token->{type}; |
|
27
|
|
|
|
|
|
|
|
|
28
|
24
|
50
|
|
|
|
63
|
if ($token_type == LEFT_PAREN) { |
|
|
|
100
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
$left_paren_num++; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
elsif ($token_type == RIGHT_PAREN) { |
|
32
|
8
|
50
|
|
|
|
13
|
if (--$left_paren_num <= 0) { |
|
33
|
8
|
|
|
|
|
9
|
my $next_token = $tokens->[++$i]; |
|
34
|
8
|
100
|
|
|
|
16
|
if ($next_token->{type} == ASSIGN) { |
|
35
|
|
|
|
|
|
|
push @violations, { |
|
36
|
|
|
|
|
|
|
filename => $file, |
|
37
|
|
|
|
|
|
|
line => $token->{line}, |
|
38
|
6
|
|
|
|
|
22
|
description => DESC, |
|
39
|
|
|
|
|
|
|
explanation => EXPL, |
|
40
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
41
|
|
|
|
|
|
|
}; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
8
|
|
|
|
|
22
|
last; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
elsif ($token_type == USE_DECL) { |
|
50
|
1
|
|
|
|
|
3
|
$token = $tokens->[++$i]; |
|
51
|
1
|
50
|
|
|
|
4
|
if ($token->{type} == DOUBLE) { |
|
52
|
1
|
|
|
|
|
3
|
($token_data = $token->{data}) =~ s/_//g; |
|
53
|
1
|
50
|
|
|
|
6
|
if ($token_data <= 5.004) { |
|
54
|
1
|
|
|
|
|
5
|
return []; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
7
|
|
|
|
|
26
|
return \@violations; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
|
64
|
|
|
|
|
|
|
|