line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::Subroutines::ProhibitBuiltinHomonyms; |
2
|
133
|
|
|
133
|
|
89954
|
use strict; |
|
133
|
|
|
|
|
295
|
|
|
133
|
|
|
|
|
4942
|
|
3
|
133
|
|
|
133
|
|
690
|
use warnings; |
|
133
|
|
|
|
|
221
|
|
|
133
|
|
|
|
|
3368
|
|
4
|
133
|
|
|
133
|
|
1337
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
206
|
|
|
133
|
|
|
|
|
82649
|
|
5
|
133
|
|
|
133
|
|
1483
|
use Perl::Lint::Keywords; |
|
133
|
|
|
|
|
265
|
|
|
133
|
|
|
|
|
9526
|
|
6
|
133
|
|
|
133
|
|
768
|
use List::Util qw/any/; |
|
133
|
|
|
|
|
244
|
|
|
133
|
|
|
|
|
8795
|
|
7
|
133
|
|
|
133
|
|
739
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
243
|
|
|
133
|
|
|
|
|
768
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use constant { |
10
|
133
|
|
|
|
|
34974
|
DESC => 'Subroutine name is a homonym for builtin %s %s', |
11
|
|
|
|
|
|
|
EXPL => [177], |
12
|
133
|
|
|
133
|
|
9391
|
}; |
|
133
|
|
|
|
|
247
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub evaluate { |
15
|
4
|
|
|
4
|
0
|
7
|
my ($class, $file, $tokens, $args) = @_; |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
|
|
6
|
my @violations; |
18
|
4
|
|
|
|
|
15
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
19
|
100
|
|
|
|
|
92
|
my $token_type = $token->{type}; |
20
|
100
|
100
|
|
|
|
189
|
if ($token_type == FUNCTION_DECL) { |
21
|
20
|
|
|
|
|
14
|
my $token = $tokens->[++$i]; |
22
|
20
|
|
|
|
|
21
|
my $token_data = $token->{data}; |
23
|
20
|
50
|
|
|
|
32
|
if ($token->{type} == FUNCTION) { |
24
|
20
|
100
|
100
|
|
|
98
|
next if $token_data eq 'import' || $token_data eq 'AUTOLOAD' || $token_data eq 'DESTROY'; |
|
|
|
100
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
17
|
|
|
|
|
13
|
my $homonym_type; |
27
|
17
|
100
|
|
|
|
31
|
if (is_perl_builtin($token_data)) { |
|
|
100
|
|
|
|
|
|
28
|
6
|
|
|
|
|
7
|
$homonym_type = 'function'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif (is_perl_bareword($token_data)) { |
31
|
8
|
|
|
|
|
9
|
$homonym_type = 'keyword'; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
3
|
|
|
|
|
6
|
next; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
14
|
|
|
|
|
75
|
push @violations, { |
38
|
|
|
|
|
|
|
filename => $file, |
39
|
|
|
|
|
|
|
line => $token->{line}, |
40
|
|
|
|
|
|
|
description => sprintf(DESC, $homonym_type, $token_data), |
41
|
|
|
|
|
|
|
explanation => EXPL, |
42
|
|
|
|
|
|
|
policy => __PACKAGE__, |
43
|
|
|
|
|
|
|
}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
|
|
16
|
return \@violations; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|