line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::Modules::RequireEndWithOne; |
2
|
133
|
|
|
133
|
|
67745
|
use strict; |
|
133
|
|
|
|
|
177
|
|
|
133
|
|
|
|
|
3148
|
|
3
|
133
|
|
|
133
|
|
402
|
use warnings; |
|
133
|
|
|
|
|
137
|
|
|
133
|
|
|
|
|
2419
|
|
4
|
133
|
|
|
133
|
|
868
|
use utf8; |
|
133
|
|
|
|
|
153
|
|
|
133
|
|
|
|
|
563
|
|
5
|
133
|
|
|
133
|
|
2856
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
170
|
|
|
133
|
|
|
|
|
58241
|
|
6
|
133
|
|
|
133
|
|
529
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
142
|
|
|
133
|
|
|
|
|
508
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant { |
9
|
133
|
|
|
|
|
30508
|
DESC => 'Module does not end with "1;"', |
10
|
|
|
|
|
|
|
EXPL => 'Must end with a recognizable true value', |
11
|
133
|
|
|
133
|
|
6352
|
}; |
|
133
|
|
|
|
|
156
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub evaluate { |
14
|
16
|
|
|
16
|
0
|
26
|
my ($class, $file, $tokens, $src, $args) = @_; |
15
|
|
|
|
|
|
|
|
16
|
16
|
|
|
|
|
14
|
my @violations; |
17
|
16
|
100
|
|
|
|
29
|
if ($src =~ /\A#!/) { # for shebang. If |
18
|
1
|
|
|
|
|
5
|
return []; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
15
|
|
|
|
|
16
|
my $last_token = $tokens->[-1]; |
22
|
15
|
|
|
|
|
16
|
my $last_token_type = $last_token->{type}; |
23
|
15
|
|
|
|
|
14
|
my $last_token_data = $last_token->{data}; |
24
|
15
|
|
|
|
|
14
|
my $before_last_token = $tokens->[-2]; |
25
|
15
|
|
|
|
|
12
|
my $before_last_token_type = $before_last_token->{type}; |
26
|
15
|
|
|
|
|
9
|
my $before_last_token_data = $before_last_token->{data}; |
27
|
15
|
|
|
|
|
15
|
my $extra_before_token = $tokens->[-3]; |
28
|
|
|
|
|
|
|
|
29
|
15
|
50
|
33
|
|
|
75
|
if (!%$last_token || !%$before_last_token) { |
30
|
0
|
|
|
|
|
0
|
return []; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
15
|
100
|
66
|
|
|
602
|
if ( |
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
34
|
|
|
|
|
|
|
!( |
35
|
|
|
|
|
|
|
$before_last_token_type == ASSIGN && |
36
|
|
|
|
|
|
|
$last_token_type == KEY && |
37
|
|
|
|
|
|
|
$last_token_data eq 'pod' |
38
|
|
|
|
|
|
|
) && |
39
|
|
|
|
|
|
|
!( |
40
|
|
|
|
|
|
|
( |
41
|
|
|
|
|
|
|
!$extra_before_token || |
42
|
|
|
|
|
|
|
$extra_before_token->{type} == SEMI_COLON || |
43
|
|
|
|
|
|
|
$extra_before_token->{type} == RIGHT_BRACE |
44
|
|
|
|
|
|
|
) && |
45
|
|
|
|
|
|
|
$before_last_token_type == INT && |
46
|
|
|
|
|
|
|
$last_token_type == SEMI_COLON && |
47
|
|
|
|
|
|
|
eval($before_last_token_data) == 1 ## no critic: to accept bin, oct and hex decimal |
48
|
|
|
|
|
|
|
) |
49
|
|
|
|
|
|
|
) { |
50
|
|
|
|
|
|
|
push @violations, { |
51
|
|
|
|
|
|
|
filename => $file, |
52
|
|
|
|
|
|
|
line => $last_token->{line}, |
53
|
5
|
|
|
|
|
20
|
description => DESC, |
54
|
|
|
|
|
|
|
explanation => EXPL, |
55
|
|
|
|
|
|
|
policy => __PACKAGE__, |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
15
|
|
|
|
|
67
|
return \@violations; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|