line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::Subroutines::ProhibitBuiltinHomonyms; |
2
|
133
|
|
|
133
|
|
67936
|
use strict; |
|
133
|
|
|
|
|
193
|
|
|
133
|
|
|
|
|
3104
|
|
3
|
133
|
|
|
133
|
|
443
|
use warnings; |
|
133
|
|
|
|
|
168
|
|
|
133
|
|
|
|
|
2446
|
|
4
|
133
|
|
|
133
|
|
795
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
167
|
|
|
133
|
|
|
|
|
60351
|
|
5
|
133
|
|
|
133
|
|
1023
|
use Perl::Lint::Keywords; |
|
133
|
|
|
|
|
184
|
|
|
133
|
|
|
|
|
7233
|
|
6
|
133
|
|
|
133
|
|
493
|
use List::Util qw/any/; |
|
133
|
|
|
|
|
180
|
|
|
133
|
|
|
|
|
5710
|
|
7
|
133
|
|
|
133
|
|
472
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
182
|
|
|
133
|
|
|
|
|
601
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use constant { |
10
|
133
|
|
|
|
|
26649
|
DESC => 'Subroutine name is a homonym for builtin %s %s', |
11
|
|
|
|
|
|
|
EXPL => [177], |
12
|
133
|
|
|
133
|
|
6886
|
}; |
|
133
|
|
|
|
|
183
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub evaluate { |
15
|
4
|
|
|
4
|
0
|
8
|
my ($class, $file, $tokens, $args) = @_; |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
|
|
5
|
my @violations; |
18
|
4
|
|
|
|
|
15
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
19
|
100
|
|
|
|
|
62
|
my $token_type = $token->{type}; |
20
|
100
|
100
|
|
|
|
160
|
if ($token_type == FUNCTION_DECL) { |
21
|
20
|
|
|
|
|
20
|
my $token = $tokens->[++$i]; |
22
|
20
|
|
|
|
|
18
|
my $token_data = $token->{data}; |
23
|
20
|
50
|
|
|
|
24
|
if ($token->{type} == FUNCTION) { |
24
|
20
|
100
|
100
|
|
|
82
|
next if $token_data eq 'import' || $token_data eq 'AUTOLOAD' || $token_data eq 'DESTROY'; |
|
|
|
100
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
17
|
|
|
|
|
12
|
my $homonym_type; |
27
|
17
|
100
|
|
|
|
29
|
if (is_perl_builtin($token_data)) { |
|
|
100
|
|
|
|
|
|
28
|
6
|
|
|
|
|
5
|
$homonym_type = 'function'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif (is_perl_bareword($token_data)) { |
31
|
8
|
|
|
|
|
6
|
$homonym_type = 'keyword'; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
3
|
|
|
|
|
7
|
next; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
push @violations, { |
38
|
|
|
|
|
|
|
filename => $file, |
39
|
|
|
|
|
|
|
line => $token->{line}, |
40
|
14
|
|
|
|
|
72
|
description => sprintf(DESC, $homonym_type, $token_data), |
41
|
|
|
|
|
|
|
explanation => EXPL, |
42
|
|
|
|
|
|
|
policy => __PACKAGE__, |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
|
|
11
|
return \@violations; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|