| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::BuiltinFunctions::ProhibitSleepViaSelect; |
|
2
|
133
|
|
|
133
|
|
70066
|
use strict; |
|
|
133
|
|
|
|
|
185
|
|
|
|
133
|
|
|
|
|
3170
|
|
|
3
|
133
|
|
|
133
|
|
474
|
use warnings; |
|
|
133
|
|
|
|
|
173
|
|
|
|
133
|
|
|
|
|
2439
|
|
|
4
|
133
|
|
|
133
|
|
863
|
use Perl::Lint::Constants::Type; |
|
|
133
|
|
|
|
|
280
|
|
|
|
133
|
|
|
|
|
58953
|
|
|
5
|
133
|
|
|
133
|
|
998
|
use Perl::Lint::Constants::Kind; |
|
|
133
|
|
|
|
|
164
|
|
|
|
133
|
|
|
|
|
6741
|
|
|
6
|
133
|
|
|
133
|
|
479
|
use parent "Perl::Lint::Policy"; |
|
|
133
|
|
|
|
|
174
|
|
|
|
133
|
|
|
|
|
557
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant { |
|
9
|
133
|
|
|
|
|
44061
|
DESC => '"select" used to emulate "sleep"', |
|
10
|
|
|
|
|
|
|
EXPL => [168], |
|
11
|
133
|
|
|
133
|
|
6521
|
}; |
|
|
133
|
|
|
|
|
194
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub evaluate { |
|
14
|
9
|
|
|
9
|
0
|
17
|
my ($class, $file, $tokens, $src, $args) = @_; |
|
15
|
|
|
|
|
|
|
|
|
16
|
9
|
|
|
|
|
20
|
my @violations; |
|
17
|
9
|
|
|
|
|
32
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
|
18
|
74
|
|
|
|
|
100
|
my $token_type = $token->{type}; |
|
19
|
74
|
|
|
|
|
76
|
my $token_data = $token->{data}; |
|
20
|
|
|
|
|
|
|
|
|
21
|
74
|
100
|
100
|
|
|
251
|
if ($token_type == BUILTIN_FUNC && $token_data eq 'select') { |
|
22
|
12
|
|
|
|
|
13
|
my $left_paren_num = 1; |
|
23
|
12
|
|
|
|
|
11
|
my $comma_num = 0; |
|
24
|
12
|
|
|
|
|
10
|
my $is_on_some_IO = 0; |
|
25
|
12
|
|
|
|
|
11
|
my $last_arg = ''; |
|
26
|
|
|
|
|
|
|
|
|
27
|
12
|
|
|
|
|
17
|
$token = $tokens->[++$i]; |
|
28
|
12
|
100
|
|
|
|
26
|
if ($token->{type} == LEFT_PAREN) { |
|
29
|
3
|
|
|
|
|
10
|
for ($i++; $token = $tokens->[$i]; $i++) { |
|
30
|
26
|
|
|
|
|
24
|
$token_type = $token->{type}; |
|
31
|
26
|
50
|
|
|
|
51
|
if ($token_type == LEFT_PAREN) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
$left_paren_num++; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
elsif ($token_type == RIGHT_PAREN) { |
|
35
|
3
|
50
|
|
|
|
6
|
if (--$left_paren_num <= 0) { |
|
36
|
3
|
|
|
|
|
4
|
my $last_arg_type = $last_arg->{type}; |
|
37
|
3
|
50
|
66
|
|
|
32
|
if (!$is_on_some_IO && $comma_num == 3 && ($last_arg_type == DOUBLE || ($last_arg_type != DEFAULT && $last_arg->{kind} == KIND_TERM))) { |
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
38
|
|
|
|
|
|
|
push @violations, { |
|
39
|
|
|
|
|
|
|
filename => $file, |
|
40
|
|
|
|
|
|
|
line => $token->{line}, |
|
41
|
2
|
|
|
|
|
9
|
description => DESC, |
|
42
|
|
|
|
|
|
|
explanation => EXPL, |
|
43
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
44
|
|
|
|
|
|
|
}; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
3
|
|
|
|
|
10
|
last; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
elsif ($token_type == COMMA) { |
|
50
|
9
|
|
|
|
|
15
|
$comma_num++; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
else { |
|
53
|
14
|
100
|
100
|
|
|
42
|
if ($comma_num < 3 && $token_type != DEFAULT) { |
|
54
|
3
|
|
|
|
|
4
|
$is_on_some_IO = 1; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
14
|
|
|
|
|
23
|
$last_arg = $token; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
else { |
|
61
|
9
|
|
|
|
|
18
|
for (; $token = $tokens->[$i]; $i++) { |
|
62
|
72
|
|
|
|
|
69
|
$token_type = $token->{type}; |
|
63
|
72
|
100
|
|
|
|
118
|
if ($token_type == SEMI_COLON) { |
|
|
|
100
|
|
|
|
|
|
|
64
|
9
|
50
|
|
|
|
19
|
if (--$left_paren_num <= 0) { |
|
65
|
9
|
|
|
|
|
10
|
my $last_arg_type = $last_arg->{type}; |
|
66
|
9
|
50
|
66
|
|
|
48
|
if (!$is_on_some_IO && $comma_num == 3 && ($last_arg_type == DOUBLE || ($last_arg_type != DEFAULT && $last_arg->{kind} == KIND_TERM))) { |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
67
|
|
|
|
|
|
|
push @violations, { |
|
68
|
|
|
|
|
|
|
filename => $file, |
|
69
|
|
|
|
|
|
|
line => $token->{line}, |
|
70
|
6
|
|
|
|
|
33
|
description => DESC, |
|
71
|
|
|
|
|
|
|
explanation => EXPL, |
|
72
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
73
|
|
|
|
|
|
|
}; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
9
|
|
|
|
|
34
|
last; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
elsif ($token_type == COMMA) { |
|
79
|
27
|
|
|
|
|
81
|
$comma_num++; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
else { |
|
82
|
36
|
100
|
100
|
|
|
115
|
if ($comma_num < 3 && $token_type != DEFAULT) { |
|
83
|
3
|
|
|
|
|
5
|
$is_on_some_IO = 1; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
36
|
|
|
|
|
81
|
$last_arg = $token; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
9
|
|
|
|
|
43
|
return \@violations; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
|
96
|
|
|
|
|
|
|
|