line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::InputOutput::ProhibitJoinedReadline; |
2
|
133
|
|
|
133
|
|
68097
|
use strict; |
|
133
|
|
|
|
|
175
|
|
|
133
|
|
|
|
|
2989
|
|
3
|
133
|
|
|
133
|
|
424
|
use warnings; |
|
133
|
|
|
|
|
154
|
|
|
133
|
|
|
|
|
2410
|
|
4
|
133
|
|
|
133
|
|
775
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
149
|
|
|
133
|
|
|
|
|
58988
|
|
5
|
133
|
|
|
133
|
|
548
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
189
|
|
|
133
|
|
|
|
|
594
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
28919
|
DESC => 'Use "local $/ = undef" or File::Slurp instead of joined readline', |
9
|
|
|
|
|
|
|
EXPL => [213], |
10
|
133
|
|
|
133
|
|
6542
|
}; |
|
133
|
|
|
|
|
168
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
5
|
|
|
5
|
0
|
6
|
my ($class, $file, $tokens, $src, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
|
|
5
|
my @violations; |
16
|
5
|
|
|
|
|
18
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
17
|
116
|
|
|
|
|
83
|
my $token_type = $token->{type}; |
18
|
116
|
|
|
|
|
76
|
my $token_data = $token->{data}; |
19
|
116
|
100
|
66
|
|
|
236
|
if ($token_type == BUILTIN_FUNC && $token_data eq 'join') { |
20
|
17
|
|
|
|
|
27
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
21
|
86
|
|
|
|
|
61
|
my $token_type = $token->{type}; |
22
|
|
|
|
|
|
|
|
23
|
86
|
100
|
|
|
|
163
|
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
|
|
|
|
|
12
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
34
|
16
|
|
|
|
|
11
|
my $token_type = $token->{type}; |
35
|
16
|
100
|
|
|
|
25
|
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
|
|
|
|
|
13
|
last; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
elsif ($token_type == SEMI_COLON) { |
48
|
17
|
|
|
|
|
29
|
last; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
5
|
|
|
|
|
16
|
return \@violations; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|