line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::RegularExpressions::ProhibitUselessTopic; |
2
|
134
|
|
|
134
|
|
68894
|
use strict; |
|
134
|
|
|
|
|
199
|
|
|
134
|
|
|
|
|
3200
|
|
3
|
134
|
|
|
134
|
|
413
|
use warnings; |
|
134
|
|
|
|
|
137
|
|
|
134
|
|
|
|
|
2588
|
|
4
|
134
|
|
|
134
|
|
756
|
use Perl::Lint::Constants::Type; |
|
134
|
|
|
|
|
138
|
|
|
134
|
|
|
|
|
60789
|
|
5
|
134
|
|
|
134
|
|
536
|
use parent "Perl::Lint::Policy"; |
|
134
|
|
|
|
|
150
|
|
|
134
|
|
|
|
|
558
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
134
|
|
|
|
|
25486
|
DESC => 'Useless use of $_', |
9
|
|
|
|
|
|
|
EXPL => '$_ should be omitted when matching a regular expression', |
10
|
134
|
|
|
134
|
|
6621
|
}; |
|
134
|
|
|
|
|
151
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
11
|
|
|
11
|
0
|
15
|
my ($class, $file, $tokens, $src, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
11
|
|
|
|
|
9
|
my @violations; |
16
|
11
|
|
|
|
|
30
|
for (my $i = 0, my $token_type; my $token = $tokens->[$i]; $i++) { |
17
|
444
|
|
|
|
|
275
|
$token_type = $token->{type}; |
18
|
|
|
|
|
|
|
|
19
|
444
|
100
|
|
|
|
715
|
if ($token_type == SPECIFIC_VALUE) { |
20
|
37
|
50
|
|
|
|
93
|
$token = $tokens->[++$i] or last; |
21
|
37
|
|
|
|
|
28
|
$token_type = $token->{type}; |
22
|
|
|
|
|
|
|
|
23
|
37
|
100
|
100
|
|
|
67
|
if ($token_type == REG_OK || $token_type == REG_NOT) { |
24
|
35
|
50
|
|
|
|
42
|
$token = $tokens->[++$i] or last; |
25
|
35
|
|
|
|
|
26
|
$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
|
|
|
|
|
36
|
return \@violations; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|