line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::InputOutput::ProhibitOneArgSelect; |
2
|
133
|
|
|
133
|
|
68882
|
use strict; |
|
133
|
|
|
|
|
241
|
|
|
133
|
|
|
|
|
3230
|
|
3
|
133
|
|
|
133
|
|
441
|
use warnings; |
|
133
|
|
|
|
|
162
|
|
|
133
|
|
|
|
|
2584
|
|
4
|
133
|
|
|
133
|
|
786
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
164
|
|
|
133
|
|
|
|
|
62224
|
|
5
|
133
|
|
|
133
|
|
598
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
186
|
|
|
133
|
|
|
|
|
626
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
35375
|
DESC => 'One-argument "select" used', |
9
|
|
|
|
|
|
|
EXPL => [224], |
10
|
133
|
|
|
133
|
|
7052
|
}; |
|
133
|
|
|
|
|
200
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
7
|
|
|
7
|
0
|
10
|
my ($class, $file, $tokens, $src, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
7
|
|
|
|
|
5
|
my @violations; |
16
|
7
|
|
|
|
|
19
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
17
|
17
|
|
|
|
|
14
|
my $token_type = $token->{type}; |
18
|
17
|
|
|
|
|
17
|
my $token_data = $token->{data}; |
19
|
|
|
|
|
|
|
|
20
|
17
|
100
|
66
|
|
|
47
|
if ($token_type == BUILTIN_FUNC && $token_data eq 'select') { |
21
|
10
|
|
|
|
|
11
|
$token = $tokens->[++$i]; |
22
|
10
|
|
|
|
|
8
|
$token_type = $token->{type}; |
23
|
10
|
100
|
|
|
|
14
|
if ($token_type == LEFT_PAREN) { |
24
|
3
|
|
|
|
|
3
|
my $args_num = 0; |
25
|
3
|
|
|
|
|
3
|
my $left_paren_num = 1; |
26
|
3
|
|
|
|
|
7
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
27
|
12
|
|
|
|
|
8
|
$token_type = $token->{type}; |
28
|
12
|
50
|
|
|
|
18
|
if ($token_type == LEFT_PAREN) { |
|
|
100
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
$left_paren_num++; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
elsif ($token_type == RIGHT_PAREN) { |
32
|
3
|
50
|
|
|
|
8
|
last if --$left_paren_num <= 0; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else { |
35
|
9
|
|
|
|
|
13
|
$args_num++; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
3
|
100
|
|
|
|
27
|
if ($args_num == 1) { |
39
|
|
|
|
|
|
|
push @violations, { |
40
|
|
|
|
|
|
|
filename => $file, |
41
|
|
|
|
|
|
|
line => $token->{line}, |
42
|
2
|
|
|
|
|
12
|
description => DESC, |
43
|
|
|
|
|
|
|
explanation => EXPL, |
44
|
|
|
|
|
|
|
policy => __PACKAGE__, |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
7
|
|
|
|
|
5
|
my $args_num = 0; |
50
|
7
|
|
|
|
|
15
|
for (; my $token = $tokens->[$i]; $i++) { |
51
|
14
|
|
|
|
|
11
|
$token_type = $token->{type}; |
52
|
14
|
100
|
|
|
|
15
|
if ($token_type == SEMI_COLON) { |
53
|
7
|
|
|
|
|
6
|
last; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
7
|
|
|
|
|
9
|
$args_num++; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
7
|
50
|
|
|
|
9
|
if ($args_num == 1) { |
60
|
|
|
|
|
|
|
push @violations, { |
61
|
|
|
|
|
|
|
filename => $file, |
62
|
|
|
|
|
|
|
line => $token->{line}, |
63
|
7
|
|
|
|
|
26
|
description => DESC, |
64
|
|
|
|
|
|
|
explanation => EXPL, |
65
|
|
|
|
|
|
|
policy => __PACKAGE__, |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
7
|
|
|
|
|
21
|
return \@violations; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|