line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::BuiltinFunctions::RequireBlockGrep; |
2
|
133
|
|
|
133
|
|
67703
|
use strict; |
|
133
|
|
|
|
|
204
|
|
|
133
|
|
|
|
|
3103
|
|
3
|
133
|
|
|
133
|
|
416
|
use warnings; |
|
133
|
|
|
|
|
174
|
|
|
133
|
|
|
|
|
2394
|
|
4
|
133
|
|
|
133
|
|
831
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
166
|
|
|
133
|
|
|
|
|
58915
|
|
5
|
133
|
|
|
133
|
|
626
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
193
|
|
|
133
|
|
|
|
|
598
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
23238
|
DESC => 'Expression form of "grep"', |
9
|
|
|
|
|
|
|
EXPL => [169], |
10
|
133
|
|
|
133
|
|
6640
|
}; |
|
133
|
|
|
|
|
166
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
4
|
|
|
4
|
0
|
7
|
my ($class, $file, $tokens, $src, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
2
|
my @violations; |
16
|
4
|
|
|
|
|
14
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
17
|
113
|
|
|
|
|
80
|
my $token_type = $token->{type}; |
18
|
113
|
|
|
|
|
75
|
my $token_data = $token->{data}; |
19
|
|
|
|
|
|
|
|
20
|
113
|
100
|
66
|
|
|
218
|
if ($token_type == BUILTIN_FUNC && $token_data eq 'grep') { |
21
|
13
|
|
|
|
|
9
|
$token = $tokens->[++$i]; |
22
|
13
|
|
|
|
|
9
|
$token_type = $token->{type}; |
23
|
13
|
100
|
|
|
|
25
|
if ($token_type == LEFT_PAREN) { |
|
|
100
|
|
|
|
|
|
24
|
4
|
|
|
|
|
8
|
next; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ($token_type != LEFT_BRACE) { |
27
|
|
|
|
|
|
|
push @violations, { |
28
|
|
|
|
|
|
|
filename => $file, |
29
|
|
|
|
|
|
|
line => $token->{line}, |
30
|
7
|
|
|
|
|
26
|
description => DESC, |
31
|
|
|
|
|
|
|
explanation => EXPL, |
32
|
|
|
|
|
|
|
policy => __PACKAGE__, |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
13
|
return \@violations; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|