line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::Subroutines::ProhibitExplicitReturnUndef; |
2
|
133
|
|
|
133
|
|
67552
|
use strict; |
|
133
|
|
|
|
|
217
|
|
|
133
|
|
|
|
|
3216
|
|
3
|
133
|
|
|
133
|
|
422
|
use warnings; |
|
133
|
|
|
|
|
173
|
|
|
133
|
|
|
|
|
2430
|
|
4
|
133
|
|
|
133
|
|
803
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
196
|
|
|
133
|
|
|
|
|
59831
|
|
5
|
133
|
|
|
133
|
|
580
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
193
|
|
|
133
|
|
|
|
|
568
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
21001
|
DESC => '"return" statement with explicit "undef"', |
9
|
|
|
|
|
|
|
EXPL => [199], |
10
|
133
|
|
|
133
|
|
6852
|
}; |
|
133
|
|
|
|
|
197
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
3
|
|
|
3
|
0
|
6
|
my ($class, $file, $tokens, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
|
|
3
|
my @violations; |
16
|
3
|
|
|
|
|
12
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
17
|
85
|
|
|
|
|
56
|
my $token_type = $token->{type}; |
18
|
|
|
|
|
|
|
|
19
|
85
|
100
|
|
|
|
141
|
if ($token_type == RETURN) { |
20
|
10
|
|
|
|
|
10
|
my $next_token = $tokens->[++$i]; |
21
|
10
|
100
|
66
|
|
|
30
|
if ($next_token->{type} == DEFAULT && $next_token->{data} eq 'undef') { |
22
|
|
|
|
|
|
|
push @violations, { |
23
|
|
|
|
|
|
|
filename => $file, |
24
|
|
|
|
|
|
|
line => $token->{line}, |
25
|
6
|
|
|
|
|
16
|
description => DESC, |
26
|
|
|
|
|
|
|
explanation => EXPL, |
27
|
|
|
|
|
|
|
policy => __PACKAGE__, |
28
|
|
|
|
|
|
|
}; |
29
|
6
|
|
|
|
|
9
|
next; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
8
|
return \@violations; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|