line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::InputOutput::RequireBracedFileHandleWithPrint; |
2
|
134
|
|
|
134
|
|
70630
|
use strict; |
|
134
|
|
|
|
|
207
|
|
|
134
|
|
|
|
|
3041
|
|
3
|
134
|
|
|
134
|
|
434
|
use warnings; |
|
134
|
|
|
|
|
159
|
|
|
134
|
|
|
|
|
2615
|
|
4
|
134
|
|
|
134
|
|
818
|
use Perl::Lint::Constants::Type; |
|
134
|
|
|
|
|
161
|
|
|
134
|
|
|
|
|
60863
|
|
5
|
134
|
|
|
134
|
|
1000
|
use Perl::Lint::Constants::Kind; |
|
134
|
|
|
|
|
202
|
|
|
134
|
|
|
|
|
6437
|
|
6
|
134
|
|
|
134
|
|
524
|
use parent "Perl::Lint::Policy"; |
|
134
|
|
|
|
|
187
|
|
|
134
|
|
|
|
|
593
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant { |
9
|
134
|
|
|
|
|
34953
|
DESC => 'File handle for "print" or "printf" is not braced', |
10
|
|
|
|
|
|
|
EXPL => [217], |
11
|
134
|
|
|
134
|
|
6592
|
}; |
|
134
|
|
|
|
|
194
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub evaluate { |
14
|
11
|
|
|
11
|
0
|
20
|
my ($class, $file, $tokens, $src, $args) = @_; |
15
|
|
|
|
|
|
|
|
16
|
11
|
|
|
|
|
12
|
my @violations; |
17
|
11
|
|
|
|
|
36
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
18
|
178
|
|
|
|
|
113
|
my $token_type = $token->{type}; |
19
|
178
|
|
|
|
|
134
|
my $token_data = $token->{data}; |
20
|
|
|
|
|
|
|
|
21
|
178
|
50
|
66
|
|
|
483
|
if ($token_type == BUILTIN_FUNC && ($token_data eq 'print' || $token_data eq 'printf' || $token_data eq 'say')) { |
|
|
|
66
|
|
|
|
|
22
|
121
|
|
|
|
|
77
|
my @function_args; |
23
|
121
|
|
|
|
|
162
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
24
|
665
|
|
|
|
|
417
|
my $token_type = $token->{type}; |
25
|
665
|
|
|
|
|
434
|
my $token_kind = $token->{kind}; |
26
|
|
|
|
|
|
|
|
27
|
665
|
100
|
100
|
|
|
1554
|
if ($token_type == SEMI_COLON) { |
|
|
100
|
|
|
|
|
|
28
|
121
|
|
|
|
|
90
|
last; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif ($token_type == LEFT_PAREN || $token_type == RIGHT_PAREN) { |
31
|
94
|
|
|
|
|
125
|
next; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
450
|
|
|
|
|
658
|
push @function_args, $token; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
121
|
100
|
|
|
|
177
|
if (scalar @function_args > 1) { |
38
|
110
|
|
|
|
|
66
|
my $first_arg = $function_args[0]; |
39
|
110
|
|
|
|
|
76
|
my $first_arg_type = $first_arg->{type}; |
40
|
110
|
|
|
|
|
67
|
my $second_arg = $function_args[1]; |
41
|
110
|
|
|
|
|
67
|
my $second_arg_type = $second_arg->{type}; |
42
|
110
|
|
|
|
|
74
|
my $second_arg_kind = $second_arg->{kind}; |
43
|
110
|
100
|
100
|
|
|
783
|
if ( |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
44
|
|
|
|
|
|
|
( |
45
|
|
|
|
|
|
|
$first_arg_type == GLOBAL_VAR || |
46
|
|
|
|
|
|
|
$first_arg_type == LOCAL_VAR || |
47
|
|
|
|
|
|
|
$first_arg_type == VAR || |
48
|
|
|
|
|
|
|
$first_arg_type == KEY |
49
|
|
|
|
|
|
|
) && |
50
|
|
|
|
|
|
|
$second_arg_kind != KIND_OP && |
51
|
|
|
|
|
|
|
$second_arg_type != COMMA && |
52
|
|
|
|
|
|
|
$second_arg_type != STRING_ADD |
53
|
|
|
|
|
|
|
) { |
54
|
|
|
|
|
|
|
push @violations, { |
55
|
|
|
|
|
|
|
filename => $file, |
56
|
|
|
|
|
|
|
line => $token->{line}, |
57
|
25
|
|
|
|
|
95
|
description => DESC, |
58
|
|
|
|
|
|
|
explanation => EXPL, |
59
|
|
|
|
|
|
|
policy => __PACKAGE__, |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
11
|
|
|
|
|
39
|
return \@violations; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|