line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::ValuesAndExpressions::RequireUpperCaseHeredocTerminator; |
2
|
134
|
|
|
134
|
|
69261
|
use strict; |
|
134
|
|
|
|
|
172
|
|
|
134
|
|
|
|
|
3199
|
|
3
|
134
|
|
|
134
|
|
402
|
use warnings; |
|
134
|
|
|
|
|
151
|
|
|
134
|
|
|
|
|
2488
|
|
4
|
134
|
|
|
134
|
|
965
|
use Perl::Lint::Constants::Type; |
|
134
|
|
|
|
|
147
|
|
|
134
|
|
|
|
|
61702
|
|
5
|
134
|
|
|
134
|
|
560
|
use parent "Perl::Lint::Policy"; |
|
134
|
|
|
|
|
154
|
|
|
134
|
|
|
|
|
562
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
134
|
|
|
|
|
26089
|
DESC => 'Heredoc terminator must be quoted', |
9
|
|
|
|
|
|
|
EXPL => [64], |
10
|
134
|
|
|
134
|
|
6799
|
}; |
|
134
|
|
|
|
|
167
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
10
|
|
|
10
|
0
|
13
|
my ($class, $file, $tokens, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
10
|
|
|
|
|
12
|
my @violations; |
16
|
10
|
|
|
|
|
31
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
17
|
104
|
|
|
|
|
80
|
my $token_type = $token->{type}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# XXX workaround |
20
|
|
|
|
|
|
|
# Compiler::Lexer cannot recognize heredoc tag as bare word and lowercase |
21
|
|
|
|
|
|
|
# https://github.com/goccy/p5-Compiler-Lexer/issues/37 |
22
|
|
|
|
|
|
|
# |
23
|
|
|
|
|
|
|
# e.g. |
24
|
|
|
|
|
|
|
# <
|
25
|
104
|
|
|
|
|
61
|
my $is_before_left_shift = 0; |
26
|
104
|
100
|
|
|
|
116
|
if ($token_type == LEFT_SHIFT) { |
27
|
8
|
|
|
|
|
12
|
$token = $tokens->[++$i]; |
28
|
8
|
|
|
|
|
9
|
$token_type = $token->{type}; |
29
|
8
|
|
|
|
|
8
|
$is_before_left_shift = 1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
104
|
100
|
100
|
|
|
428
|
if ( |
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
33
|
|
|
|
|
|
|
$token_type == HERE_DOCUMENT_TAG || |
34
|
|
|
|
|
|
|
$token_type == HERE_DOCUMENT_RAW_TAG || |
35
|
|
|
|
|
|
|
($is_before_left_shift && $token_type == KEY) |
36
|
|
|
|
|
|
|
) { |
37
|
7
|
100
|
|
|
|
28
|
if ($token->{data} =~ /[a-z]/) { |
38
|
|
|
|
|
|
|
push @violations, { |
39
|
|
|
|
|
|
|
filename => $file, |
40
|
|
|
|
|
|
|
line => $token->{line}, |
41
|
4
|
|
|
|
|
29
|
description => DESC, |
42
|
|
|
|
|
|
|
explanation => EXPL, |
43
|
|
|
|
|
|
|
policy => __PACKAGE__, |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
10
|
|
|
|
|
36
|
return \@violations; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|