line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::RegularExpressions::ProhibitUselessTopic; |
2
|
134
|
|
|
134
|
|
69338
|
use strict; |
|
134
|
|
|
|
|
163
|
|
|
134
|
|
|
|
|
3029
|
|
3
|
134
|
|
|
134
|
|
435
|
use warnings; |
|
134
|
|
|
|
|
145
|
|
|
134
|
|
|
|
|
2407
|
|
4
|
134
|
|
|
134
|
|
746
|
use Perl::Lint::Constants::Type; |
|
134
|
|
|
|
|
129
|
|
|
134
|
|
|
|
|
60076
|
|
5
|
134
|
|
|
134
|
|
563
|
use parent "Perl::Lint::Policy"; |
|
134
|
|
|
|
|
138
|
|
|
134
|
|
|
|
|
545
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
134
|
|
|
|
|
24689
|
DESC => 'Useless use of $_', |
9
|
|
|
|
|
|
|
EXPL => '$_ should be omitted when matching a regular expression', |
10
|
134
|
|
|
134
|
|
6493
|
}; |
|
134
|
|
|
|
|
175
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
11
|
|
|
11
|
0
|
16
|
my ($class, $file, $tokens, $src, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
11
|
|
|
|
|
19
|
my @violations; |
16
|
11
|
|
|
|
|
30
|
for (my $i = 0, my $token_type; my $token = $tokens->[$i]; $i++) { |
17
|
444
|
|
|
|
|
282
|
$token_type = $token->{type}; |
18
|
|
|
|
|
|
|
|
19
|
444
|
100
|
|
|
|
703
|
if ($token_type == SPECIFIC_VALUE) { |
20
|
37
|
50
|
|
|
|
48
|
$token = $tokens->[++$i] or last; |
21
|
37
|
|
|
|
|
28
|
$token_type = $token->{type}; |
22
|
|
|
|
|
|
|
|
23
|
37
|
100
|
100
|
|
|
70
|
if ($token_type == REG_OK || $token_type == REG_NOT) { |
24
|
35
|
50
|
|
|
|
51
|
$token = $tokens->[++$i] or last; |
25
|
35
|
|
|
|
|
21
|
$token_type = $token->{type}; |
26
|
|
|
|
|
|
|
|
27
|
35
|
100
|
100
|
|
|
95
|
if ($token_type != VAR && $token_type != GLOBAL_VAR) { |
28
|
|
|
|
|
|
|
push @violations, { |
29
|
|
|
|
|
|
|
filename => $file, |
30
|
|
|
|
|
|
|
line => $token->{line}, |
31
|
30
|
|
|
|
|
97
|
description => DESC, |
32
|
|
|
|
|
|
|
explanation => EXPL, |
33
|
|
|
|
|
|
|
policy => __PACKAGE__, |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
11
|
|
|
|
|
32
|
return \@violations; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|