line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::ControlStructures::ProhibitUnlessBlocks; |
2
|
134
|
|
|
134
|
|
69215
|
use strict; |
|
134
|
|
|
|
|
168
|
|
|
134
|
|
|
|
|
3237
|
|
3
|
134
|
|
|
134
|
|
423
|
use warnings; |
|
134
|
|
|
|
|
139
|
|
|
134
|
|
|
|
|
2493
|
|
4
|
134
|
|
|
134
|
|
765
|
use Perl::Lint::Constants::Type; |
|
134
|
|
|
|
|
146
|
|
|
134
|
|
|
|
|
60344
|
|
5
|
134
|
|
|
134
|
|
561
|
use parent "Perl::Lint::Policy"; |
|
134
|
|
|
|
|
153
|
|
|
134
|
|
|
|
|
562
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant { |
8
|
134
|
|
|
|
|
27235
|
DESC => '"unless" block used', |
9
|
|
|
|
|
|
|
EXPL => [97], |
10
|
134
|
|
|
134
|
|
6831
|
}; |
|
134
|
|
|
|
|
194
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub evaluate { |
13
|
5
|
|
|
5
|
0
|
12
|
my ($class, $file, $tokens, $src, $args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
|
|
6
|
my @violations; |
16
|
5
|
|
|
|
|
23
|
for (my $i = 0; my $token = $tokens->[$i]; $i++) { |
17
|
102
|
|
|
|
|
71
|
my $token_type = $token->{type}; |
18
|
|
|
|
|
|
|
|
19
|
102
|
100
|
|
|
|
177
|
if ($token_type == UNLESS_STATEMENT) { |
20
|
7
|
100
|
|
|
|
18
|
if ($tokens->[++$i]->{type} == LEFT_PAREN) { |
21
|
6
|
|
|
|
|
13
|
my $left_paren_num = 1; |
22
|
6
|
|
|
|
|
16
|
for ($i++; my $token = $tokens->[$i]; $i++) { |
23
|
12
|
|
|
|
|
12
|
my $token_type = $token->{type}; |
24
|
12
|
50
|
|
|
|
36
|
if ($token_type == LEFT_PAREN) { |
|
|
100
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
$left_paren_num++; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif ($token_type == RIGHT_PAREN) { |
28
|
6
|
50
|
|
|
|
14
|
last if --$left_paren_num <= 0; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
6
|
50
|
|
|
|
13
|
if ($tokens->[++$i]->{type} == LEFT_BRACE) { |
32
|
|
|
|
|
|
|
push @violations, { |
33
|
|
|
|
|
|
|
filename => $file, |
34
|
|
|
|
|
|
|
line => $token->{line}, |
35
|
6
|
|
|
|
|
33
|
description => DESC, |
36
|
|
|
|
|
|
|
explanation => EXPL, |
37
|
|
|
|
|
|
|
policy => __PACKAGE__, |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
5
|
|
|
|
|
18
|
return \@violations; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|