line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::Subroutines::ProhibitBuiltinHomonyms; |
2
|
133
|
|
|
133
|
|
67021
|
use strict; |
|
133
|
|
|
|
|
210
|
|
|
133
|
|
|
|
|
3192
|
|
3
|
133
|
|
|
133
|
|
422
|
use warnings; |
|
133
|
|
|
|
|
162
|
|
|
133
|
|
|
|
|
2420
|
|
4
|
133
|
|
|
133
|
|
799
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
158
|
|
|
133
|
|
|
|
|
60080
|
|
5
|
133
|
|
|
133
|
|
1118
|
use Perl::Lint::Keywords; |
|
133
|
|
|
|
|
218
|
|
|
133
|
|
|
|
|
7355
|
|
6
|
133
|
|
|
133
|
|
522
|
use List::Util qw/any/; |
|
133
|
|
|
|
|
185
|
|
|
133
|
|
|
|
|
6014
|
|
7
|
133
|
|
|
133
|
|
479
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
183
|
|
|
133
|
|
|
|
|
608
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use constant { |
10
|
133
|
|
|
|
|
26698
|
DESC => 'Subroutine name is a homonym for builtin %s %s', |
11
|
|
|
|
|
|
|
EXPL => [177], |
12
|
133
|
|
|
133
|
|
7527
|
}; |
|
133
|
|
|
|
|
188
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub evaluate { |
15
|
4
|
|
|
4
|
0
|
7
|
my ($class, $file, $tokens, $args) = @_; |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
|
|
4
|
my @violations; |
18
|
4
|
|
|
|
|
13
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
19
|
100
|
|
|
|
|
69
|
my $token_type = $token->{type}; |
20
|
100
|
100
|
|
|
|
161
|
if ($token_type == FUNCTION_DECL) { |
21
|
20
|
|
|
|
|
17
|
my $token = $tokens->[++$i]; |
22
|
20
|
|
|
|
|
15
|
my $token_data = $token->{data}; |
23
|
20
|
50
|
|
|
|
26
|
if ($token->{type} == FUNCTION) { |
24
|
20
|
100
|
100
|
|
|
84
|
next if $token_data eq 'import' || $token_data eq 'AUTOLOAD' || $token_data eq 'DESTROY'; |
|
|
|
100
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
17
|
|
|
|
|
11
|
my $homonym_type; |
27
|
17
|
100
|
|
|
|
30
|
if (is_perl_builtin($token_data)) { |
|
|
100
|
|
|
|
|
|
28
|
6
|
|
|
|
|
6
|
$homonym_type = 'function'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif (is_perl_bareword($token_data)) { |
31
|
8
|
|
|
|
|
7
|
$homonym_type = 'keyword'; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
3
|
|
|
|
|
6
|
next; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
push @violations, { |
38
|
|
|
|
|
|
|
filename => $file, |
39
|
|
|
|
|
|
|
line => $token->{line}, |
40
|
14
|
|
|
|
|
77
|
description => sprintf(DESC, $homonym_type, $token_data), |
41
|
|
|
|
|
|
|
explanation => EXPL, |
42
|
|
|
|
|
|
|
policy => __PACKAGE__, |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
|
|
13
|
return \@violations; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|