line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::Subroutines::ProhibitExplicitReturnUndef; |
2
|
133
|
|
|
133
|
|
91542
|
use strict; |
|
133
|
|
|
|
|
300
|
|
|
133
|
|
|
|
|
5031
|
|
3
|
133
|
|
|
133
|
|
681
|
use warnings; |
|
133
|
|
|
|
|
265
|
|
|
133
|
|
|
|
|
3391
|
|
4
|
133
|
|
|
133
|
|
1078
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
246
|
|
|
133
|
|
|
|
|
82361
|
|
5
|
133
|
|
|
133
|
|
884
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
243
|
|
|
133
|
|
|
|
|
762
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
26935
|
DESC => '"return" statement with explicit "undef"', |
9
|
|
|
|
|
|
|
EXPL => [199], |
10
|
133
|
|
|
133
|
|
8807
|
}; |
|
133
|
|
|
|
|
248
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
3
|
|
|
3
|
0
|
4
|
my ($class, $file, $tokens, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
|
|
4
|
my @violations; |
16
|
3
|
|
|
|
|
12
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
17
|
85
|
|
|
|
|
60
|
my $token_type = $token->{type}; |
18
|
|
|
|
|
|
|
|
19
|
85
|
100
|
|
|
|
163
|
if ($token_type == RETURN) { |
20
|
10
|
|
|
|
|
11
|
my $next_token = $tokens->[++$i]; |
21
|
10
|
100
|
66
|
|
|
33
|
if ($next_token->{type} == DEFAULT && $next_token->{data} eq 'undef') { |
22
|
6
|
|
|
|
|
18
|
push @violations, { |
23
|
|
|
|
|
|
|
filename => $file, |
24
|
|
|
|
|
|
|
line => $token->{line}, |
25
|
|
|
|
|
|
|
description => DESC, |
26
|
|
|
|
|
|
|
explanation => EXPL, |
27
|
|
|
|
|
|
|
policy => __PACKAGE__, |
28
|
|
|
|
|
|
|
}; |
29
|
6
|
|
|
|
|
14
|
next; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
11
|
return \@violations; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|