line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::BuiltinFunctions::RequireBlockGrep; |
2
|
133
|
|
|
133
|
|
67470
|
use strict; |
|
133
|
|
|
|
|
179
|
|
|
133
|
|
|
|
|
3168
|
|
3
|
133
|
|
|
133
|
|
418
|
use warnings; |
|
133
|
|
|
|
|
178
|
|
|
133
|
|
|
|
|
2423
|
|
4
|
133
|
|
|
133
|
|
959
|
use Perl::Lint::Constants::Type; |
|
133
|
|
|
|
|
152
|
|
|
133
|
|
|
|
|
59299
|
|
5
|
133
|
|
|
133
|
|
599
|
use parent "Perl::Lint::Policy"; |
|
133
|
|
|
|
|
196
|
|
|
133
|
|
|
|
|
617
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
133
|
|
|
|
|
23216
|
DESC => 'Expression form of "grep"', |
9
|
|
|
|
|
|
|
EXPL => [169], |
10
|
133
|
|
|
133
|
|
6852
|
}; |
|
133
|
|
|
|
|
218
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
4
|
|
|
4
|
0
|
7
|
my ($class, $file, $tokens, $src, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
|
|
4
|
my @violations; |
16
|
4
|
|
|
|
|
16
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
17
|
113
|
|
|
|
|
78
|
my $token_type = $token->{type}; |
18
|
113
|
|
|
|
|
81
|
my $token_data = $token->{data}; |
19
|
|
|
|
|
|
|
|
20
|
113
|
100
|
66
|
|
|
275
|
if ($token_type == BUILTIN_FUNC && $token_data eq 'grep') { |
21
|
13
|
|
|
|
|
12
|
$token = $tokens->[++$i]; |
22
|
13
|
|
|
|
|
11
|
$token_type = $token->{type}; |
23
|
13
|
100
|
|
|
|
25
|
if ($token_type == LEFT_PAREN) { |
|
|
100
|
|
|
|
|
|
24
|
4
|
|
|
|
|
7
|
next; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ($token_type != LEFT_BRACE) { |
27
|
|
|
|
|
|
|
push @violations, { |
28
|
|
|
|
|
|
|
filename => $file, |
29
|
|
|
|
|
|
|
line => $token->{line}, |
30
|
7
|
|
|
|
|
27
|
description => DESC, |
31
|
|
|
|
|
|
|
explanation => EXPL, |
32
|
|
|
|
|
|
|
policy => __PACKAGE__, |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
16
|
return \@violations; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|