line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::InputOutput::RequireEncodingWithUTF8Layer; |
2
|
133
|
|
|
133
|
|
95749
|
use strict; |
|
133
|
|
|
|
|
267
|
|
|
133
|
|
|
|
|
4992
|
|
3
|
133
|
|
|
133
|
|
662
|
use warnings; |
|
133
|
|
|
|
|
223
|
|
|
133
|
|
|
|
|
3484
|
|
4
|
133
|
|
|
133
|
|
952
|
use Perl::Lint::Constants::Kind; |
|
133
|
|
|
|
|
206
|
|
|
133
|
|
|
|
|
8709
|
|
5
|
133
|
|
|
133
|
|
1289
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
288
|
|
|
133
|
|
|
|
|
85911
|
|
6
|
133
|
|
|
133
|
|
1481
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
238
|
|
|
133
|
|
|
|
|
835
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant { |
9
|
133
|
|
|
|
|
45173
|
DESC => 'I/O layer ":utf8" used', |
10
|
|
|
|
|
|
|
EXPL => 'Use ":encoding(UTF-8)" to get strict validation', |
11
|
133
|
|
|
133
|
|
13810
|
}; |
|
133
|
|
|
|
|
312
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub evaluate { |
14
|
3
|
|
|
3
|
0
|
46
|
my ($class, $file, $tokens, $src, $args) = @_; |
15
|
|
|
|
|
|
|
|
16
|
3
|
|
|
|
|
6
|
my @violations; |
17
|
3
|
|
|
|
|
26
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
18
|
223
|
|
|
|
|
457
|
my $token_type = $token->{type}; |
19
|
223
|
|
|
|
|
600
|
my $token_data = $token->{data}; |
20
|
|
|
|
|
|
|
|
21
|
223
|
100
|
100
|
|
|
1128
|
if ($token_type == BUILTIN_FUNC && ($token_data eq 'open' || $token_data eq 'binmode')) { |
|
|
|
66
|
|
|
|
|
22
|
90
|
|
|
|
|
95
|
my @args; |
23
|
90
|
|
|
|
|
207
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
24
|
498
|
|
|
|
|
734
|
my $token_type = $token->{type}; |
25
|
498
|
|
|
|
|
587
|
my $token_kind = $token->{kind}; |
26
|
498
|
100
|
100
|
|
|
15147
|
if ($token_type == RIGHT_PAREN || $token_kind == KIND_STMT_END || $token_kind == KIND_OP) { |
|
|
100
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
27
|
90
|
|
|
|
|
159
|
last; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
elsif ( |
30
|
|
|
|
|
|
|
$token_type != COMMA && |
31
|
|
|
|
|
|
|
$token_type != REG_DOUBLE_QUOTE && |
32
|
|
|
|
|
|
|
$token_type != REG_QUOTE && |
33
|
|
|
|
|
|
|
$token_type != REG_DELIM && |
34
|
|
|
|
|
|
|
$token_type != LEFT_PAREN && |
35
|
|
|
|
|
|
|
$token_kind != KIND_DECL |
36
|
|
|
|
|
|
|
) { |
37
|
218
|
|
|
|
|
969
|
push @args, $token->{data}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
90
|
|
|
|
|
127
|
my $second_arg = $args[1]; |
41
|
90
|
100
|
100
|
|
|
675
|
if ($second_arg && $second_arg =~ /utf8\Z/) { |
42
|
38
|
|
|
|
|
327
|
push @violations, { |
43
|
|
|
|
|
|
|
filename => $file, |
44
|
|
|
|
|
|
|
line => $token->{line}, |
45
|
|
|
|
|
|
|
description => DESC, |
46
|
|
|
|
|
|
|
explanation => EXPL, |
47
|
|
|
|
|
|
|
policy => __PACKAGE__, |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
45
|
return \@violations; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|