line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::InputOutput::ProhibitJoinedReadline; |
2
|
133
|
|
|
133
|
|
67966
|
use strict; |
|
133
|
|
|
|
|
187
|
|
|
133
|
|
|
|
|
3281
|
|
3
|
133
|
|
|
133
|
|
418
|
use warnings; |
|
133
|
|
|
|
|
167
|
|
|
133
|
|
|
|
|
2624
|
|
4
|
133
|
|
|
133
|
|
775
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
158
|
|
|
133
|
|
|
|
|
61104
|
|
5
|
133
|
|
|
133
|
|
581
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
181
|
|
|
133
|
|
|
|
|
609
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
30011
|
DESC => 'Use "local $/ = undef" or File::Slurp instead of joined readline', |
9
|
|
|
|
|
|
|
EXPL => [213], |
10
|
133
|
|
|
133
|
|
6945
|
}; |
|
133
|
|
|
|
|
177
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
5
|
|
|
5
|
0
|
7
|
my ($class, $file, $tokens, $src, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
|
|
5
|
my @violations; |
16
|
5
|
|
|
|
|
15
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
17
|
116
|
|
|
|
|
84
|
my $token_type = $token->{type}; |
18
|
116
|
|
|
|
|
75
|
my $token_data = $token->{data}; |
19
|
116
|
100
|
66
|
|
|
235
|
if ($token_type == BUILTIN_FUNC && $token_data eq 'join') { |
20
|
17
|
|
|
|
|
21
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
21
|
86
|
|
|
|
|
69
|
my $token_type = $token->{type}; |
22
|
|
|
|
|
|
|
|
23
|
86
|
100
|
|
|
|
162
|
if ($token_type == DIAMOND) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
24
|
|
|
|
|
|
|
push @violations, { |
25
|
|
|
|
|
|
|
filename => $file, |
26
|
|
|
|
|
|
|
line => $token->{line}, |
27
|
9
|
|
|
|
|
31
|
description => DESC, |
28
|
|
|
|
|
|
|
explanation => EXPL, |
29
|
|
|
|
|
|
|
policy => __PACKAGE__, |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
elsif ($token_type == HANDLE_DELIM) { |
33
|
8
|
|
|
|
|
11
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
34
|
16
|
|
|
|
|
14
|
my $token_type = $token->{type}; |
35
|
16
|
100
|
|
|
|
23
|
if ($token_type == HANDLE_DELIM) { |
36
|
|
|
|
|
|
|
push @violations, { |
37
|
|
|
|
|
|
|
filename => $file, |
38
|
|
|
|
|
|
|
line => $token->{line}, |
39
|
8
|
|
|
|
|
20
|
description => DESC, |
40
|
|
|
|
|
|
|
explanation => EXPL, |
41
|
|
|
|
|
|
|
policy => __PACKAGE__, |
42
|
|
|
|
|
|
|
}; |
43
|
8
|
|
|
|
|
11
|
last; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
elsif ($token_type == SEMI_COLON) { |
48
|
17
|
|
|
|
|
30
|
last; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
5
|
|
|
|
|
14
|
return \@violations; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|