line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::InputOutput::ProhibitJoinedReadline; |
2
|
133
|
|
|
133
|
|
99669
|
use strict; |
|
133
|
|
|
|
|
257
|
|
|
133
|
|
|
|
|
4839
|
|
3
|
133
|
|
|
133
|
|
677
|
use warnings; |
|
133
|
|
|
|
|
210
|
|
|
133
|
|
|
|
|
3346
|
|
4
|
133
|
|
|
133
|
|
932
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
205
|
|
|
133
|
|
|
|
|
80423
|
|
5
|
133
|
|
|
133
|
|
789
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
241
|
|
|
133
|
|
|
|
|
842
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
38612
|
DESC => 'Use "local $/ = undef" or File::Slurp instead of joined readline', |
9
|
|
|
|
|
|
|
EXPL => [213], |
10
|
133
|
|
|
133
|
|
8628
|
}; |
|
133
|
|
|
|
|
249
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
5
|
|
|
5
|
0
|
17
|
my ($class, $file, $tokens, $src, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
|
|
7
|
my @violations; |
16
|
5
|
|
|
|
|
27
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
17
|
116
|
|
|
|
|
132
|
my $token_type = $token->{type}; |
18
|
116
|
|
|
|
|
224
|
my $token_data = $token->{data}; |
19
|
116
|
100
|
66
|
|
|
386
|
if ($token_type == BUILTIN_FUNC && $token_data eq 'join') { |
20
|
17
|
|
|
|
|
42
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
21
|
86
|
|
|
|
|
99
|
my $token_type = $token->{type}; |
22
|
|
|
|
|
|
|
|
23
|
86
|
100
|
|
|
|
294
|
if ($token_type == DIAMOND) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
24
|
9
|
|
|
|
|
61
|
push @violations, { |
25
|
|
|
|
|
|
|
filename => $file, |
26
|
|
|
|
|
|
|
line => $token->{line}, |
27
|
|
|
|
|
|
|
description => DESC, |
28
|
|
|
|
|
|
|
explanation => EXPL, |
29
|
|
|
|
|
|
|
policy => __PACKAGE__, |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
elsif ($token_type == HANDLE_DELIM) { |
33
|
8
|
|
|
|
|
22
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
34
|
16
|
|
|
|
|
19
|
my $token_type = $token->{type}; |
35
|
16
|
100
|
|
|
|
40
|
if ($token_type == HANDLE_DELIM) { |
36
|
8
|
|
|
|
|
39
|
push @violations, { |
37
|
|
|
|
|
|
|
filename => $file, |
38
|
|
|
|
|
|
|
line => $token->{line}, |
39
|
|
|
|
|
|
|
description => DESC, |
40
|
|
|
|
|
|
|
explanation => EXPL, |
41
|
|
|
|
|
|
|
policy => __PACKAGE__, |
42
|
|
|
|
|
|
|
}; |
43
|
8
|
|
|
|
|
23
|
last; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
elsif ($token_type == SEMI_COLON) { |
48
|
17
|
|
|
|
|
47
|
last; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
5
|
|
|
|
|
45
|
return \@violations; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|