| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Lint::Policy::RegularExpressions::ProhibitUnusedCapture; |
|
2
|
133
|
|
|
133
|
|
80582
|
use strict; |
|
|
133
|
|
|
|
|
164
|
|
|
|
133
|
|
|
|
|
2982
|
|
|
3
|
133
|
|
|
133
|
|
394
|
use warnings; |
|
|
133
|
|
|
|
|
190
|
|
|
|
133
|
|
|
|
|
2731
|
|
|
4
|
133
|
|
|
133
|
|
397
|
use List::Util qw/any all/; |
|
|
133
|
|
|
|
|
144
|
|
|
|
133
|
|
|
|
|
6975
|
|
|
5
|
133
|
|
|
133
|
|
54039
|
use Test::Deep::NoTest qw(eq_deeply); |
|
|
133
|
|
|
|
|
859478
|
|
|
|
133
|
|
|
|
|
755
|
|
|
6
|
133
|
|
|
133
|
|
20492
|
use Perl::Lint::Constants::Type; |
|
|
133
|
|
|
|
|
172
|
|
|
|
133
|
|
|
|
|
61643
|
|
|
7
|
133
|
|
|
133
|
|
571
|
use parent "Perl::Lint::Policy"; |
|
|
133
|
|
|
|
|
177
|
|
|
|
133
|
|
|
|
|
649
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use constant { |
|
10
|
133
|
|
|
|
|
392383
|
DESC => 'Only use a capturing group if you plan to use the captured value', |
|
11
|
|
|
|
|
|
|
EXPL => [252], |
|
12
|
133
|
|
|
133
|
|
6980
|
}; |
|
|
133
|
|
|
|
|
184
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my %ignore_reg_op = ( |
|
15
|
|
|
|
|
|
|
®_LIST => 1, |
|
16
|
|
|
|
|
|
|
®_EXEC => 1, |
|
17
|
|
|
|
|
|
|
®_QUOTE => 1, |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my @captured_for_each_scope; |
|
21
|
|
|
|
|
|
|
my $sub_depth; |
|
22
|
|
|
|
|
|
|
my @violations; |
|
23
|
|
|
|
|
|
|
my $file; |
|
24
|
|
|
|
|
|
|
my $tokens; |
|
25
|
|
|
|
|
|
|
my $just_before_regex_token; |
|
26
|
|
|
|
|
|
|
my $reg_not_ctx; |
|
27
|
|
|
|
|
|
|
my $assign_ctx; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub evaluate { |
|
30
|
49
|
|
|
49
|
0
|
52
|
my $class = shift; |
|
31
|
49
|
|
|
|
|
43
|
$file = shift; |
|
32
|
49
|
|
|
|
|
55
|
$tokens = shift; |
|
33
|
49
|
|
|
|
|
766
|
my ($src, $args) = @_; |
|
34
|
|
|
|
|
|
|
|
|
35
|
49
|
|
|
|
|
43
|
my $is_used_english = 0; |
|
36
|
|
|
|
|
|
|
|
|
37
|
49
|
|
|
|
|
74
|
@violations = (); |
|
38
|
49
|
|
|
|
|
104
|
@captured_for_each_scope = ({}); |
|
39
|
49
|
|
|
|
|
43
|
$just_before_regex_token = undef; |
|
40
|
49
|
|
|
|
|
62
|
$assign_ctx = 'NONE'; |
|
41
|
49
|
|
|
|
|
46
|
$reg_not_ctx = 0; |
|
42
|
|
|
|
|
|
|
|
|
43
|
49
|
|
|
|
|
31
|
my %depth_for_each_subs; |
|
44
|
49
|
|
|
|
|
38
|
my $lbnum_for_scope = 0; |
|
45
|
49
|
|
|
|
|
33
|
$sub_depth = 0; |
|
46
|
|
|
|
|
|
|
|
|
47
|
49
|
|
|
|
|
129
|
TOP: for (my $i = 0, my $token_type, my $token_data; my $token = $tokens->[$i]; $i++) { |
|
48
|
1508
|
|
|
|
|
1090
|
$token_type = $token->{type}; |
|
49
|
1508
|
|
|
|
|
1108
|
$token_data = $token->{data}; |
|
50
|
|
|
|
|
|
|
|
|
51
|
1508
|
100
|
66
|
|
|
2019
|
if ($token_type == USED_NAME && $token_data eq 'English') { |
|
52
|
3
|
|
|
|
|
2
|
$is_used_english = 1; |
|
53
|
3
|
|
|
|
|
8
|
next; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# to ignore regexp which is not pattern matching |
|
57
|
|
|
|
|
|
|
# NOTE: Compiler::Lexer handles all of the content of q*{} operator as regexp token |
|
58
|
1505
|
100
|
|
|
|
1849
|
if ($ignore_reg_op{$token_type}) { |
|
59
|
9
|
|
|
|
|
8
|
$i += 2; # skip content |
|
60
|
9
|
|
|
|
|
15
|
next; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
1496
|
100
|
|
|
|
1692
|
if ($token_type == ASSIGN) { |
|
64
|
63
|
50
|
|
|
|
122
|
$token = $tokens->[$i-1] or next; |
|
65
|
63
|
|
|
|
|
54
|
$token_type = $token->{type}; |
|
66
|
|
|
|
|
|
|
|
|
67
|
63
|
|
|
|
|
51
|
$assign_ctx = 'ANY'; # XXX Any!? |
|
68
|
|
|
|
|
|
|
|
|
69
|
63
|
100
|
100
|
|
|
582
|
if ( |
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$token_type == GLOBAL_VAR || |
|
71
|
|
|
|
|
|
|
$token_type == LOCAL_VAR || |
|
72
|
|
|
|
|
|
|
$token_type == VAR |
|
73
|
|
|
|
|
|
|
) { |
|
74
|
13
|
|
|
|
|
11
|
$assign_ctx = 'SUCCESS'; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
elsif ( |
|
77
|
|
|
|
|
|
|
$token_type == GLOBAL_ARRAY_VAR || |
|
78
|
|
|
|
|
|
|
$token_type == LOCAL_ARRAY_VAR || |
|
79
|
|
|
|
|
|
|
$token_type == ARRAY_VAR |
|
80
|
|
|
|
|
|
|
) { |
|
81
|
11
|
|
|
|
|
10
|
$assign_ctx = 'UNLIMITED_ARRAY'; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
elsif ( |
|
84
|
|
|
|
|
|
|
$token_type == GLOBAL_HASH_VAR || |
|
85
|
|
|
|
|
|
|
$token_type == LOCAL_HASH_VAR || |
|
86
|
|
|
|
|
|
|
$token_type == HASH_VAR |
|
87
|
|
|
|
|
|
|
) { |
|
88
|
1
|
|
|
|
|
2
|
$assign_ctx = 'UNLIMITED'; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
elsif ($token_type == RIGHT_PAREN) { |
|
91
|
34
|
|
|
|
|
28
|
$assign_ctx = 'LIMITED'; |
|
92
|
|
|
|
|
|
|
|
|
93
|
34
|
50
|
|
|
|
52
|
$token = $tokens->[$i-2] or next; |
|
94
|
34
|
|
|
|
|
25
|
$token_type = $token->{type}; |
|
95
|
34
|
100
|
|
|
|
64
|
if ($token_type == LEFT_PAREN) { |
|
|
|
100
|
|
|
|
|
|
|
96
|
2
|
|
|
|
|
3
|
$assign_ctx = 'UNLIMITED'; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
elsif ($token_type == DEFAULT) { |
|
99
|
1
|
50
|
|
|
|
5
|
$token = $tokens->[$i-3] or next; |
|
100
|
1
|
|
|
|
|
2
|
$token_type = $token->{type}; |
|
101
|
1
|
50
|
|
|
|
3
|
if ($token_type == LEFT_PAREN) { |
|
102
|
1
|
|
|
|
|
2
|
$assign_ctx = 'UNLIMITED'; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
63
|
50
|
|
|
|
111
|
$token = $tokens->[$i+1] or next; |
|
108
|
63
|
|
|
|
|
39
|
$token_type = $token->{type}; |
|
109
|
63
|
100
|
100
|
|
|
166
|
if ($token_type == LEFT_BRACE || $token_type == LEFT_BRACKET) { |
|
110
|
2
|
|
|
|
|
2
|
$assign_ctx = 'UNLIMITED'; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
63
|
|
|
|
|
99
|
next; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
1433
|
100
|
|
|
|
1577
|
if ($token_type == SEMI_COLON) { |
|
117
|
169
|
|
|
|
|
126
|
$assign_ctx = 'NONE'; |
|
118
|
169
|
|
|
|
|
256
|
next; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
1264
|
100
|
|
|
|
1357
|
if ($token_type == REG_NOT) { |
|
122
|
2
|
|
|
|
|
3
|
$reg_not_ctx = 1; |
|
123
|
2
|
|
|
|
|
4
|
next; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
1262
|
100
|
|
|
|
1376
|
if ($token_type == REG_DOUBLE_QUOTE) { |
|
127
|
3
|
|
|
|
|
3
|
$i += 2; # jump to string |
|
128
|
3
|
|
|
|
|
4
|
$token = $tokens->[$i]; |
|
129
|
3
|
|
|
|
|
3
|
$token_type = STRING; # XXX Violence!! |
|
130
|
|
|
|
|
|
|
# fall through |
|
131
|
|
|
|
|
|
|
} |
|
132
|
1262
|
100
|
100
|
|
|
3100
|
if ($token_type == STRING || $token_type == HERE_DOCUMENT) { |
|
133
|
28
|
|
|
|
|
54
|
my @chars = split //, $token_data; |
|
134
|
28
|
|
|
|
|
19
|
my $is_var = 0; |
|
135
|
28
|
|
|
|
|
18
|
my $escaped = 0; |
|
136
|
28
|
|
|
|
|
45
|
for (my $j = 0; my $char = $chars[$j]; $j++) { |
|
137
|
83
|
100
|
|
|
|
98
|
if ($escaped) { |
|
138
|
7
|
50
|
|
|
|
16
|
if ($char =~ /[0-9]/) { |
|
139
|
|
|
|
|
|
|
# TODO should track follows number |
|
140
|
0
|
|
|
|
|
0
|
delete $captured_for_each_scope[$sub_depth]->{q<$> . $char}; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
7
|
|
|
|
|
6
|
$escaped = 0; |
|
143
|
7
|
|
|
|
|
13
|
next; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
76
|
100
|
|
|
|
86
|
if ($is_var) { |
|
147
|
7
|
50
|
|
|
|
14
|
if ($char =~ /[a-zA-Z_]/) { |
|
148
|
0
|
|
|
|
|
0
|
my $var_name = $char; |
|
149
|
0
|
|
|
|
|
0
|
for ($j++; $char = $chars[$j]; $j++) { |
|
150
|
0
|
0
|
|
|
|
0
|
if ($char !~ /[0-9a-zA-Z_]/) { |
|
151
|
0
|
|
|
|
|
0
|
$j--; |
|
152
|
0
|
|
|
|
|
0
|
last; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
0
|
|
|
|
|
0
|
$var_name .= $char; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
0
|
0
|
0
|
|
|
0
|
if (!$is_used_english) { |
|
|
|
0
|
0
|
|
|
|
|
|
158
|
0
|
|
|
|
|
0
|
next; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
elsif ( |
|
161
|
|
|
|
|
|
|
$var_name eq 'LAST_PAREN_MATCH' || |
|
162
|
|
|
|
|
|
|
$var_name eq 'LAST_MATCH_END' || |
|
163
|
|
|
|
|
|
|
$var_name eq 'LAST_MATCH_START' |
|
164
|
|
|
|
|
|
|
) { |
|
165
|
0
|
|
|
|
|
0
|
$char = '+'; # XXX |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
else { |
|
168
|
0
|
|
|
|
|
0
|
next; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
7
|
100
|
|
|
|
9
|
if ($char eq '{') { |
|
173
|
1
|
|
|
|
|
2
|
my $var_name = ''; |
|
174
|
1
|
|
|
|
|
4
|
for ($j++; $char = $chars[$j]; $j++) { |
|
175
|
2
|
100
|
|
|
|
5
|
if ($char eq '}') { |
|
176
|
1
|
|
|
|
|
2
|
last; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
else { |
|
179
|
1
|
|
|
|
|
4
|
$var_name .= $char; |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
} |
|
182
|
1
|
|
|
|
|
3
|
delete $captured_for_each_scope[$sub_depth]->{q<$> . $var_name}; |
|
183
|
1
|
|
|
|
|
2
|
next; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
6
|
100
|
33
|
|
|
19
|
if ($char =~ /[0-9]/) { |
|
|
|
50
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
# TODO should track follows number |
|
188
|
3
|
|
|
|
|
6
|
delete $captured_for_each_scope[$sub_depth]->{q<$> . $char}; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
elsif ( |
|
191
|
|
|
|
|
|
|
$char eq '+' || $char eq '-' |
|
192
|
|
|
|
|
|
|
) { |
|
193
|
3
|
|
|
|
|
3
|
my $lbnum = 1; |
|
194
|
3
|
|
|
|
|
3
|
my $captured_name = ''; |
|
195
|
|
|
|
|
|
|
|
|
196
|
3
|
|
|
|
|
4
|
my $begin_delimiter = '{'; |
|
197
|
3
|
|
|
|
|
3
|
my $end_delimiter = '}'; |
|
198
|
3
|
50
|
|
|
|
5
|
$char = $chars[++$j] or next; |
|
199
|
3
|
100
|
|
|
|
5
|
if ($char eq '[') { |
|
200
|
2
|
|
|
|
|
3
|
$begin_delimiter = '['; |
|
201
|
2
|
|
|
|
|
2
|
$end_delimiter = ']'; |
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
|
|
204
|
3
|
|
|
|
|
7
|
for ($j++; $char = $chars[$j]; $j++) { |
|
205
|
8
|
50
|
|
|
|
16
|
if ($char eq $begin_delimiter) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
0
|
$lbnum++; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
elsif ($char eq $end_delimiter) { |
|
209
|
3
|
50
|
|
|
|
7
|
last if --$lbnum <= 0; |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
elsif ($char ne ' ') { |
|
212
|
5
|
|
|
|
|
10
|
$captured_name .= $char; |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
|
|
216
|
3
|
100
|
|
|
|
5
|
if ($begin_delimiter eq '[') { |
|
217
|
2
|
50
|
|
|
|
6
|
$captured_name-- if $captured_name > 0; |
|
218
|
|
|
|
|
|
|
|
|
219
|
2
|
|
|
|
|
3
|
my @num_vars = sort {$a cmp $b} grep { $_ =~ /\A\$[0-9]+\Z/} keys %{$captured_for_each_scope[$sub_depth]}; |
|
|
2
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
16
|
|
|
|
2
|
|
|
|
|
6
|
|
|
220
|
|
|
|
|
|
|
|
|
221
|
2
|
50
|
|
|
|
6
|
if (my $hit = $num_vars[$captured_name]) { |
|
222
|
2
|
|
|
|
|
5
|
delete $captured_for_each_scope[$sub_depth]->{$hit}; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
else { |
|
226
|
1
|
|
|
|
|
3
|
delete $captured_for_each_scope[$sub_depth]->{$captured_name}; |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
|
|
230
|
6
|
|
|
|
|
4
|
$is_var = 0; |
|
231
|
6
|
|
|
|
|
9
|
next; |
|
232
|
|
|
|
|
|
|
} |
|
233
|
|
|
|
|
|
|
|
|
234
|
69
|
100
|
|
|
|
78
|
if ($char eq '\\') { |
|
235
|
7
|
|
|
|
|
7
|
$escaped = 1; |
|
236
|
7
|
|
|
|
|
12
|
next; |
|
237
|
|
|
|
|
|
|
} |
|
238
|
|
|
|
|
|
|
|
|
239
|
62
|
100
|
|
|
|
117
|
if ($char eq q<$>) { |
|
240
|
6
|
|
|
|
|
9
|
$is_var = 1; |
|
241
|
6
|
|
|
|
|
8
|
next; |
|
242
|
|
|
|
|
|
|
} |
|
243
|
|
|
|
|
|
|
} |
|
244
|
28
|
|
|
|
|
54
|
next; |
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
|
|
247
|
1234
|
100
|
|
|
|
1344
|
if ($token_type == REG_REPLACE_TO) { |
|
248
|
22
|
|
|
|
|
20
|
my $escaped = 0; |
|
249
|
22
|
|
|
|
|
16
|
my $is_var = 0; |
|
250
|
22
|
|
|
|
|
57
|
my @re_chars = split //, $token_data; |
|
251
|
22
|
|
|
|
|
43
|
for (my $j = 0; my $re_char = $re_chars[$j]; $j++) { |
|
252
|
103
|
100
|
|
|
|
108
|
if ($escaped) { |
|
253
|
2
|
100
|
|
|
|
4
|
if ($re_char =~ /[0-9]/) { |
|
254
|
|
|
|
|
|
|
# TODO should track follows number |
|
255
|
1
|
|
|
|
|
3
|
delete $captured_for_each_scope[$sub_depth]->{q<$> . $re_char}; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
2
|
|
|
|
|
2
|
$escaped = 0; |
|
258
|
2
|
|
|
|
|
4
|
next; |
|
259
|
|
|
|
|
|
|
} |
|
260
|
|
|
|
|
|
|
|
|
261
|
101
|
100
|
|
|
|
105
|
if ($is_var) { |
|
262
|
30
|
100
|
|
|
|
74
|
if ($re_char =~ /[a-zA-Z_]/) { |
|
263
|
11
|
|
|
|
|
11
|
my $var_name = $re_char; |
|
264
|
11
|
|
|
|
|
20
|
for ($j++; $re_char = $re_chars[$j]; $j++) { |
|
265
|
159
|
100
|
|
|
|
248
|
if ($re_char !~ /[0-9a-zA-Z_]/) { |
|
266
|
11
|
|
|
|
|
8
|
$j--; |
|
267
|
11
|
|
|
|
|
10
|
last; |
|
268
|
|
|
|
|
|
|
} |
|
269
|
148
|
|
|
|
|
211
|
$var_name .= $re_char; |
|
270
|
|
|
|
|
|
|
} |
|
271
|
|
|
|
|
|
|
|
|
272
|
11
|
100
|
100
|
|
|
39
|
if (!$is_used_english) { |
|
|
|
50
|
66
|
|
|
|
|
|
273
|
6
|
|
|
|
|
11
|
next; |
|
274
|
|
|
|
|
|
|
} |
|
275
|
|
|
|
|
|
|
elsif ( |
|
276
|
|
|
|
|
|
|
$var_name eq 'LAST_PAREN_MATCH' || |
|
277
|
|
|
|
|
|
|
$var_name eq 'LAST_MATCH_END' || |
|
278
|
|
|
|
|
|
|
$var_name eq 'LAST_MATCH_START' |
|
279
|
|
|
|
|
|
|
) { |
|
280
|
5
|
|
|
|
|
9
|
$re_char = '+'; # XXX |
|
281
|
|
|
|
|
|
|
} |
|
282
|
|
|
|
|
|
|
else { |
|
283
|
0
|
|
|
|
|
0
|
next; |
|
284
|
|
|
|
|
|
|
} |
|
285
|
|
|
|
|
|
|
} |
|
286
|
|
|
|
|
|
|
|
|
287
|
24
|
100
|
|
|
|
32
|
if ($re_char eq '{') { |
|
288
|
2
|
|
|
|
|
3
|
my $var_name = ''; |
|
289
|
2
|
|
|
|
|
6
|
for ($j++; $re_char = $re_chars[$j]; $j++) { |
|
290
|
7
|
100
|
|
|
|
8
|
if ($re_char eq '}') { |
|
291
|
2
|
|
|
|
|
3
|
last; |
|
292
|
|
|
|
|
|
|
} |
|
293
|
|
|
|
|
|
|
else { |
|
294
|
5
|
|
|
|
|
9
|
$var_name .= $re_char; |
|
295
|
|
|
|
|
|
|
} |
|
296
|
|
|
|
|
|
|
} |
|
297
|
2
|
|
|
|
|
4
|
delete $captured_for_each_scope[$sub_depth]->{q<$> . $var_name}; |
|
298
|
2
|
|
|
|
|
5
|
next; |
|
299
|
|
|
|
|
|
|
} |
|
300
|
|
|
|
|
|
|
|
|
301
|
22
|
100
|
100
|
|
|
91
|
if ($re_char =~ /[0-9]/) { |
|
|
|
100
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
# TODO should track follows number |
|
303
|
7
|
|
|
|
|
15
|
delete $captured_for_each_scope[$sub_depth]->{q<$> . $re_char}; |
|
304
|
|
|
|
|
|
|
} |
|
305
|
|
|
|
|
|
|
elsif ( |
|
306
|
|
|
|
|
|
|
$re_char eq '+' || $re_char eq '-' |
|
307
|
|
|
|
|
|
|
) { |
|
308
|
10
|
|
|
|
|
7
|
my $lbnum = 1; |
|
309
|
10
|
|
|
|
|
11
|
my $captured_name = ''; |
|
310
|
|
|
|
|
|
|
|
|
311
|
10
|
|
|
|
|
9
|
my $begin_delimiter = '{'; |
|
312
|
10
|
|
|
|
|
6
|
my $end_delimiter = '}'; |
|
313
|
10
|
50
|
|
|
|
19
|
$re_char = $re_chars[++$j] or next; |
|
314
|
10
|
100
|
|
|
|
14
|
if ($re_char eq '[') { |
|
315
|
8
|
|
|
|
|
7
|
$begin_delimiter = '['; |
|
316
|
8
|
|
|
|
|
6
|
$end_delimiter = ']'; |
|
317
|
|
|
|
|
|
|
} |
|
318
|
|
|
|
|
|
|
|
|
319
|
10
|
|
|
|
|
18
|
for (; $re_char = $re_chars[$j]; $j++) { |
|
320
|
54
|
100
|
|
|
|
98
|
if ($re_char eq $begin_delimiter) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
321
|
10
|
|
|
|
|
17
|
$lbnum++; |
|
322
|
|
|
|
|
|
|
} |
|
323
|
|
|
|
|
|
|
elsif ($re_char eq $end_delimiter) { |
|
324
|
10
|
50
|
|
|
|
22
|
last if --$lbnum <= 0; |
|
325
|
|
|
|
|
|
|
} |
|
326
|
|
|
|
|
|
|
elsif ($re_char ne ' ') { |
|
327
|
18
|
|
|
|
|
30
|
$captured_name .= $re_char; |
|
328
|
|
|
|
|
|
|
} |
|
329
|
|
|
|
|
|
|
} |
|
330
|
|
|
|
|
|
|
|
|
331
|
10
|
100
|
|
|
|
14
|
if ($begin_delimiter eq '[') { |
|
332
|
8
|
100
|
|
|
|
16
|
$captured_name-- if $captured_name > 0; |
|
333
|
|
|
|
|
|
|
|
|
334
|
8
|
|
|
|
|
7
|
my @num_vars = sort {$a cmp $b} grep { $_ =~ /\A\$[0-9]+\Z/} keys %{$captured_for_each_scope[$sub_depth]}; |
|
|
0
|
|
|
|
|
0
|
|
|
|
8
|
|
|
|
|
35
|
|
|
|
8
|
|
|
|
|
20
|
|
|
335
|
|
|
|
|
|
|
|
|
336
|
8
|
50
|
|
|
|
18
|
if (my $hit = $num_vars[$captured_name]) { |
|
337
|
8
|
|
|
|
|
13
|
delete $captured_for_each_scope[$sub_depth]->{$hit}; |
|
338
|
|
|
|
|
|
|
} |
|
339
|
|
|
|
|
|
|
} |
|
340
|
|
|
|
|
|
|
else { |
|
341
|
2
|
|
|
|
|
5
|
delete $captured_for_each_scope[$sub_depth]->{$captured_name}; |
|
342
|
|
|
|
|
|
|
} |
|
343
|
|
|
|
|
|
|
} |
|
344
|
|
|
|
|
|
|
|
|
345
|
22
|
|
|
|
|
19
|
$is_var = 0; |
|
346
|
22
|
|
|
|
|
43
|
next; |
|
347
|
|
|
|
|
|
|
} |
|
348
|
|
|
|
|
|
|
|
|
349
|
71
|
100
|
|
|
|
84
|
if ($re_char eq '\\') { |
|
350
|
2
|
|
|
|
|
3
|
$escaped = 1; |
|
351
|
2
|
|
|
|
|
4
|
next; |
|
352
|
|
|
|
|
|
|
} |
|
353
|
|
|
|
|
|
|
|
|
354
|
69
|
100
|
|
|
|
110
|
if ($re_char eq q<$>) { |
|
355
|
23
|
|
|
|
|
17
|
$is_var = 1; |
|
356
|
23
|
|
|
|
|
61
|
next; |
|
357
|
|
|
|
|
|
|
} |
|
358
|
|
|
|
|
|
|
} |
|
359
|
|
|
|
|
|
|
|
|
360
|
22
|
|
|
|
|
57
|
next; |
|
361
|
|
|
|
|
|
|
} |
|
362
|
|
|
|
|
|
|
|
|
363
|
1212
|
100
|
100
|
|
|
2736
|
if ($token_type == REG_EXP || $token_type == REG_REPLACE_FROM) { |
|
364
|
90
|
100
|
66
|
|
|
126
|
if (defined $captured_for_each_scope[$sub_depth] && %{$captured_for_each_scope[$sub_depth]}) { |
|
|
90
|
|
|
|
|
270
|
|
|
365
|
|
|
|
|
|
|
push @violations, { |
|
366
|
|
|
|
|
|
|
filename => $file, |
|
367
|
|
|
|
|
|
|
line => $just_before_regex_token->{line}, |
|
368
|
10
|
|
|
|
|
36
|
description => DESC, |
|
369
|
|
|
|
|
|
|
explanation => EXPL, |
|
370
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
371
|
|
|
|
|
|
|
}; |
|
372
|
|
|
|
|
|
|
} |
|
373
|
|
|
|
|
|
|
|
|
374
|
90
|
|
|
|
|
99
|
$captured_for_each_scope[$sub_depth] = {}; |
|
375
|
90
|
|
|
|
|
97
|
$just_before_regex_token = $token; |
|
376
|
|
|
|
|
|
|
|
|
377
|
90
|
|
|
|
|
199
|
my @re_chars = split //, $token_data; |
|
378
|
|
|
|
|
|
|
|
|
379
|
90
|
|
|
|
|
75
|
my $escaped = 0; |
|
380
|
90
|
|
|
|
|
61
|
my $lbnum = 0; |
|
381
|
90
|
|
|
|
|
63
|
my $captured_num = 0; |
|
382
|
90
|
|
|
|
|
170
|
for (my $j = 0; my $re_char = $re_chars[$j]; $j++) { |
|
383
|
608
|
100
|
|
|
|
665
|
if ($escaped) { |
|
384
|
38
|
100
|
|
|
|
79
|
if ($re_char =~ /[0-9]/) { |
|
385
|
|
|
|
|
|
|
# TODO should track follows number |
|
386
|
1
|
|
|
|
|
3
|
delete $captured_for_each_scope[$sub_depth]->{q<$> . $re_char}; |
|
387
|
|
|
|
|
|
|
} |
|
388
|
38
|
|
|
|
|
36
|
$escaped = 0; |
|
389
|
38
|
|
|
|
|
50
|
next; |
|
390
|
|
|
|
|
|
|
} |
|
391
|
|
|
|
|
|
|
|
|
392
|
570
|
100
|
|
|
|
648
|
if ($re_char eq '\\') { |
|
393
|
38
|
|
|
|
|
28
|
$escaped = 1; |
|
394
|
38
|
|
|
|
|
55
|
next; |
|
395
|
|
|
|
|
|
|
} |
|
396
|
|
|
|
|
|
|
|
|
397
|
532
|
100
|
|
|
|
593
|
if ($re_char eq '[') { |
|
398
|
3
|
|
|
|
|
3
|
$lbnum++; |
|
399
|
3
|
|
|
|
|
3
|
next; |
|
400
|
|
|
|
|
|
|
} |
|
401
|
|
|
|
|
|
|
|
|
402
|
529
|
100
|
|
|
|
610
|
if ($lbnum > 0) { # in [...] |
|
403
|
6
|
100
|
|
|
|
9
|
if ($re_char eq ']') { |
|
404
|
3
|
|
|
|
|
2
|
$lbnum--; |
|
405
|
3
|
|
|
|
|
7
|
next; |
|
406
|
|
|
|
|
|
|
} |
|
407
|
|
|
|
|
|
|
|
|
408
|
3
|
|
|
|
|
5
|
next; |
|
409
|
|
|
|
|
|
|
} |
|
410
|
|
|
|
|
|
|
|
|
411
|
523
|
100
|
|
|
|
869
|
if ($re_char eq '(') { |
|
412
|
113
|
|
|
|
|
83
|
my $captured_name = ''; |
|
413
|
|
|
|
|
|
|
|
|
414
|
113
|
100
|
33
|
|
|
319
|
if ($re_chars[$j+1] eq '?') { |
|
|
|
50
|
|
|
|
|
|
|
415
|
18
|
|
|
|
|
15
|
my $delimiter = $re_chars[$j+2]; |
|
416
|
|
|
|
|
|
|
|
|
417
|
18
|
100
|
|
|
|
28
|
if ($delimiter eq ':') { |
|
418
|
3
|
|
|
|
|
9
|
next; |
|
419
|
|
|
|
|
|
|
} |
|
420
|
|
|
|
|
|
|
|
|
421
|
15
|
100
|
|
|
|
19
|
if ($delimiter eq 'P') { |
|
422
|
3
|
|
|
|
|
5
|
$delimiter = $re_chars[$j+3]; |
|
423
|
3
|
|
|
|
|
4
|
$j++; |
|
424
|
|
|
|
|
|
|
} |
|
425
|
|
|
|
|
|
|
|
|
426
|
15
|
50
|
66
|
|
|
33
|
if ($delimiter eq '<' || $delimiter eq q{'}) { |
|
427
|
15
|
|
|
|
|
26
|
for ($j += 3; $re_char = $re_chars[$j]; $j++) { |
|
428
|
60
|
100
|
100
|
|
|
220
|
if ( |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
429
|
|
|
|
|
|
|
($delimiter eq '<' && $re_char eq '>') || |
|
430
|
|
|
|
|
|
|
($delimiter eq q{'} && $re_char eq q{'}) |
|
431
|
|
|
|
|
|
|
) { |
|
432
|
15
|
|
|
|
|
16
|
last; |
|
433
|
|
|
|
|
|
|
} |
|
434
|
45
|
|
|
|
|
74
|
$captured_name .= $re_char; |
|
435
|
|
|
|
|
|
|
} |
|
436
|
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
|
|
438
|
15
|
50
|
|
|
|
20
|
if ($reg_not_ctx) { |
|
439
|
|
|
|
|
|
|
push @violations, { |
|
440
|
|
|
|
|
|
|
filename => $file, |
|
441
|
|
|
|
|
|
|
line => $token->{line}, |
|
442
|
0
|
|
|
|
|
0
|
description => DESC, |
|
443
|
|
|
|
|
|
|
explanation => EXPL, |
|
444
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
445
|
|
|
|
|
|
|
}; |
|
446
|
|
|
|
|
|
|
} |
|
447
|
|
|
|
|
|
|
else { |
|
448
|
15
|
|
|
|
|
13
|
$captured_num++; |
|
449
|
15
|
|
|
|
|
42
|
$captured_for_each_scope[$sub_depth]->{$captured_name} = 1; |
|
450
|
|
|
|
|
|
|
} |
|
451
|
|
|
|
|
|
|
} |
|
452
|
|
|
|
|
|
|
} |
|
453
|
|
|
|
|
|
|
elsif ($re_chars[$j+1] ne '?' || $re_chars[$j+2] ne ':') { |
|
454
|
95
|
100
|
|
|
|
103
|
if ($reg_not_ctx) { |
|
455
|
|
|
|
|
|
|
push @violations, { |
|
456
|
|
|
|
|
|
|
filename => $file, |
|
457
|
|
|
|
|
|
|
line => $token->{line}, |
|
458
|
2
|
|
|
|
|
11
|
description => DESC, |
|
459
|
|
|
|
|
|
|
explanation => EXPL, |
|
460
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
461
|
|
|
|
|
|
|
}; |
|
462
|
|
|
|
|
|
|
} |
|
463
|
|
|
|
|
|
|
else { |
|
464
|
93
|
|
|
|
|
63
|
$captured_num++; |
|
465
|
93
|
|
|
|
|
244
|
$captured_for_each_scope[$sub_depth]->{q<$> . $captured_num} = 1; |
|
466
|
|
|
|
|
|
|
} |
|
467
|
|
|
|
|
|
|
} |
|
468
|
|
|
|
|
|
|
} |
|
469
|
|
|
|
|
|
|
} |
|
470
|
|
|
|
|
|
|
|
|
471
|
90
|
100
|
|
|
|
139
|
if ($assign_ctx ne 'NONE') { |
|
472
|
33
|
|
|
|
|
24
|
my $captured = $captured_for_each_scope[$sub_depth]; |
|
473
|
|
|
|
|
|
|
|
|
474
|
33
|
100
|
|
|
|
48
|
if ($assign_ctx eq 'UNLIMITED_ARRAY') { |
|
475
|
8
|
50
|
|
|
|
9
|
if (%{$captured || {}}) { |
|
|
8
|
50
|
|
|
|
20
|
|
|
476
|
8
|
100
|
|
10
|
|
59
|
if (all {substr($_, 0, 1) eq q<$> } keys %$captured) { |
|
|
10
|
|
|
|
|
25
|
|
|
477
|
6
|
|
|
|
|
8
|
$captured_for_each_scope[$sub_depth] = {}; |
|
478
|
|
|
|
|
|
|
} |
|
479
|
|
|
|
|
|
|
} |
|
480
|
8
|
|
|
|
|
33
|
next; |
|
481
|
|
|
|
|
|
|
} |
|
482
|
|
|
|
|
|
|
|
|
483
|
25
|
|
|
|
|
24
|
$captured_for_each_scope[$sub_depth] = {}; |
|
484
|
|
|
|
|
|
|
|
|
485
|
25
|
50
|
|
|
|
39
|
my $maybe_reg_opt = $tokens->[$i+2] or next; |
|
486
|
25
|
100
|
|
|
|
40
|
if ($maybe_reg_opt->{type} == REG_OPT) { |
|
487
|
6
|
100
|
66
|
|
|
22
|
if ($assign_ctx ne 'UNLIMITED' && $maybe_reg_opt->{data} =~ /g/) { |
|
488
|
|
|
|
|
|
|
push @violations, { |
|
489
|
|
|
|
|
|
|
filename => $file, |
|
490
|
|
|
|
|
|
|
line => $token->{line}, |
|
491
|
2
|
|
|
|
|
8
|
description => DESC, |
|
492
|
|
|
|
|
|
|
explanation => EXPL, |
|
493
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
494
|
|
|
|
|
|
|
}; |
|
495
|
|
|
|
|
|
|
} |
|
496
|
|
|
|
|
|
|
} |
|
497
|
|
|
|
|
|
|
|
|
498
|
25
|
|
|
|
|
69
|
next; |
|
499
|
|
|
|
|
|
|
} |
|
500
|
|
|
|
|
|
|
|
|
501
|
57
|
|
|
|
|
50
|
$reg_not_ctx = 0; |
|
502
|
|
|
|
|
|
|
|
|
503
|
57
|
|
|
|
|
150
|
next; |
|
504
|
|
|
|
|
|
|
} |
|
505
|
|
|
|
|
|
|
|
|
506
|
1122
|
100
|
|
|
|
1274
|
if ($token_type == BUILTIN_FUNC) { |
|
507
|
78
|
100
|
100
|
|
|
204
|
if ($token_data eq 'grep' || $token_data eq 'map') { |
|
508
|
7
|
50
|
|
|
|
15
|
$token = $tokens->[++$i] or last; |
|
509
|
7
|
|
|
|
|
7
|
$token_type = $token->{type}; |
|
510
|
|
|
|
|
|
|
|
|
511
|
7
|
50
|
|
|
|
12
|
if ($token_type == LEFT_PAREN) { |
|
512
|
0
|
|
|
|
|
0
|
my $lpnum = 1; |
|
513
|
0
|
|
|
|
|
0
|
for ($i++; $token = $tokens->[$i]; $i++) { |
|
514
|
0
|
|
|
|
|
0
|
$token_type = $token->{type}; |
|
515
|
0
|
0
|
|
|
|
0
|
if ($token_type == LEFT_PAREN) { |
|
|
|
0
|
|
|
|
|
|
|
516
|
0
|
|
|
|
|
0
|
$lpnum++; |
|
517
|
|
|
|
|
|
|
} |
|
518
|
|
|
|
|
|
|
elsif ($token_type == RIGHT_PAREN) { |
|
519
|
0
|
0
|
|
|
|
0
|
last if --$lpnum <= 0; |
|
520
|
|
|
|
|
|
|
} |
|
521
|
|
|
|
|
|
|
} |
|
522
|
|
|
|
|
|
|
} |
|
523
|
|
|
|
|
|
|
else { |
|
524
|
7
|
|
|
|
|
17
|
for ($i++; $token = $tokens->[$i]; $i++) { |
|
525
|
78
|
100
|
|
|
|
127
|
if ($token->{type} == SEMI_COLON) { |
|
526
|
7
|
|
|
|
|
10
|
last; |
|
527
|
|
|
|
|
|
|
} |
|
528
|
|
|
|
|
|
|
} |
|
529
|
|
|
|
|
|
|
} |
|
530
|
|
|
|
|
|
|
|
|
531
|
7
|
|
|
|
|
13
|
next; |
|
532
|
|
|
|
|
|
|
} |
|
533
|
|
|
|
|
|
|
} |
|
534
|
|
|
|
|
|
|
|
|
535
|
1115
|
100
|
66
|
|
|
3729
|
if ( |
|
|
|
|
100
|
|
|
|
|
|
536
|
|
|
|
|
|
|
$token_type == BUILTIN_FUNC || |
|
537
|
|
|
|
|
|
|
$token_type == METHOD || |
|
538
|
|
|
|
|
|
|
$token_type == KEY |
|
539
|
|
|
|
|
|
|
) { |
|
540
|
86
|
|
|
|
|
75
|
my $j = $i + 1; |
|
541
|
86
|
50
|
|
|
|
121
|
$token = $tokens->[$j] or last; |
|
542
|
86
|
|
|
|
|
78
|
$token_type = $token->{type}; |
|
543
|
86
|
100
|
|
|
|
91
|
if ($token_type == LEFT_PAREN) { |
|
544
|
10
|
|
|
|
|
11
|
my $lpnum = 1; |
|
545
|
10
|
|
|
|
|
22
|
for ($j++; $token = $tokens->[$j]; $j++) { |
|
546
|
122
|
|
|
|
|
76
|
$token_type = $token->{type}; |
|
547
|
122
|
50
|
|
|
|
279
|
if ($token_type == LEFT_PAREN) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
548
|
0
|
|
|
|
|
0
|
$lpnum++; |
|
549
|
|
|
|
|
|
|
} |
|
550
|
|
|
|
|
|
|
elsif ($token_type == RIGHT_PAREN) { |
|
551
|
10
|
50
|
|
|
|
19
|
last if --$lpnum <= 0; |
|
552
|
|
|
|
|
|
|
} |
|
553
|
|
|
|
|
|
|
elsif ($token_type == REG_EXP) { |
|
554
|
3
|
|
|
|
|
6
|
$token->{type} = -1; # XXX Replace to NOP |
|
555
|
|
|
|
|
|
|
} |
|
556
|
|
|
|
|
|
|
} |
|
557
|
|
|
|
|
|
|
} |
|
558
|
|
|
|
|
|
|
else { |
|
559
|
76
|
|
|
|
|
130
|
for (my $j = $i + 1; $token = $tokens->[$j]; $j++) { |
|
560
|
366
|
|
|
|
|
223
|
$token_type = $token->{type}; |
|
561
|
366
|
100
|
|
|
|
705
|
if ($token_type == SEMI_COLON) { |
|
|
|
100
|
|
|
|
|
|
|
562
|
75
|
|
|
|
|
65
|
last; |
|
563
|
|
|
|
|
|
|
} |
|
564
|
|
|
|
|
|
|
elsif ($token_type == REG_EXP) { |
|
565
|
9
|
|
|
|
|
16
|
$token->{type} = -1; # XXX Replace to NOP |
|
566
|
|
|
|
|
|
|
} |
|
567
|
|
|
|
|
|
|
} |
|
568
|
|
|
|
|
|
|
} |
|
569
|
|
|
|
|
|
|
|
|
570
|
86
|
|
|
|
|
117
|
next; |
|
571
|
|
|
|
|
|
|
} |
|
572
|
|
|
|
|
|
|
|
|
573
|
1029
|
50
|
66
|
|
|
3569
|
if ( |
|
|
|
|
66
|
|
|
|
|
|
574
|
|
|
|
|
|
|
$token_type == IF_STATEMENT || |
|
575
|
|
|
|
|
|
|
$token_type == ELSIF_STATEMENT || |
|
576
|
|
|
|
|
|
|
$token_type == UNLESS_STATEMENT |
|
577
|
|
|
|
|
|
|
) { |
|
578
|
27
|
50
|
|
|
|
43
|
$token = $tokens->[++$i] or next; |
|
579
|
|
|
|
|
|
|
|
|
580
|
27
|
|
|
|
|
29
|
my @regexs_at_before_and_op; |
|
581
|
|
|
|
|
|
|
my @regexs_at_after_and_op; |
|
582
|
0
|
|
|
|
|
0
|
my $and_op_token; |
|
583
|
|
|
|
|
|
|
|
|
584
|
27
|
50
|
|
|
|
56
|
if ($token->{type} eq LEFT_PAREN) { |
|
585
|
27
|
|
|
|
|
24
|
my $lpnum = 1; |
|
586
|
27
|
|
|
|
|
46
|
for ($i++; $token = $tokens->[$i]; $i++) { |
|
587
|
158
|
|
|
|
|
126
|
$token_type = $token->{type}; |
|
588
|
158
|
100
|
100
|
|
|
657
|
if ($token_type == LEFT_PAREN) { |
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
589
|
1
|
|
|
|
|
2
|
$lpnum++; |
|
590
|
|
|
|
|
|
|
} |
|
591
|
|
|
|
|
|
|
elsif ($token_type == RIGHT_PAREN) { |
|
592
|
28
|
100
|
|
|
|
52
|
last if --$lpnum <= 0; |
|
593
|
|
|
|
|
|
|
} |
|
594
|
|
|
|
|
|
|
elsif ($token_type == REG_EXP) { |
|
595
|
29
|
100
|
|
|
|
35
|
if ($and_op_token) { |
|
596
|
3
|
|
|
|
|
6
|
push @regexs_at_after_and_op, $token; |
|
597
|
|
|
|
|
|
|
} |
|
598
|
|
|
|
|
|
|
else { |
|
599
|
26
|
|
|
|
|
44
|
push @regexs_at_before_and_op, $token; |
|
600
|
|
|
|
|
|
|
} |
|
601
|
|
|
|
|
|
|
} |
|
602
|
|
|
|
|
|
|
elsif ($token_type == AND || $token_type == ALPHABET_AND) { |
|
603
|
3
|
|
|
|
|
7
|
$and_op_token = $token; |
|
604
|
|
|
|
|
|
|
} |
|
605
|
|
|
|
|
|
|
elsif ($ignore_reg_op{$token_type} || $token_type == REG_DOUBLE_QUOTE) { # XXX |
|
606
|
8
|
|
|
|
|
16
|
$i += 2; |
|
607
|
|
|
|
|
|
|
} |
|
608
|
|
|
|
|
|
|
} |
|
609
|
|
|
|
|
|
|
} |
|
610
|
|
|
|
|
|
|
else { |
|
611
|
0
|
|
|
|
|
0
|
for ($i++; $token = $tokens->[$i]; $i++) { |
|
612
|
0
|
|
|
|
|
0
|
$token_type = $token->{type}; |
|
613
|
0
|
0
|
0
|
|
|
0
|
if ($token_type == SEMI_COLON) { |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
614
|
0
|
|
|
|
|
0
|
last; |
|
615
|
|
|
|
|
|
|
} |
|
616
|
|
|
|
|
|
|
elsif ($token_type == REG_EXP) { |
|
617
|
0
|
0
|
|
|
|
0
|
if ($and_op_token) { |
|
618
|
0
|
|
|
|
|
0
|
push @regexs_at_after_and_op, $token; |
|
619
|
|
|
|
|
|
|
} |
|
620
|
|
|
|
|
|
|
else { |
|
621
|
0
|
|
|
|
|
0
|
push @regexs_at_before_and_op, $token; |
|
622
|
|
|
|
|
|
|
} |
|
623
|
|
|
|
|
|
|
} |
|
624
|
|
|
|
|
|
|
elsif ($token_type == AND || $token_type == ALPHABET_AND) { |
|
625
|
0
|
|
|
|
|
0
|
$and_op_token = $token; |
|
626
|
|
|
|
|
|
|
} |
|
627
|
|
|
|
|
|
|
elsif ($ignore_reg_op{$token_type} || $token_type == REG_DOUBLE_QUOTE) { # XXX |
|
628
|
0
|
|
|
|
|
0
|
$i += 2; |
|
629
|
|
|
|
|
|
|
} |
|
630
|
|
|
|
|
|
|
} |
|
631
|
|
|
|
|
|
|
} |
|
632
|
|
|
|
|
|
|
|
|
633
|
27
|
100
|
|
|
|
40
|
if (!@regexs_at_after_and_op) { |
|
634
|
24
|
|
|
|
|
21
|
my @captured; |
|
635
|
24
|
|
|
|
|
34
|
for my $regex (@regexs_at_before_and_op) { |
|
636
|
20
|
|
|
|
|
54
|
$class->_scan_regex($regex, $i); |
|
637
|
|
|
|
|
|
|
|
|
638
|
20
|
|
|
|
|
17
|
push @captured, $captured_for_each_scope[$sub_depth]; |
|
639
|
20
|
|
|
|
|
36
|
$captured_for_each_scope[++$sub_depth] = {}; |
|
640
|
|
|
|
|
|
|
} |
|
641
|
|
|
|
|
|
|
|
|
642
|
24
|
|
|
|
|
23
|
my $datam = pop @captured; |
|
643
|
24
|
100
|
|
|
|
36
|
if ($datam) { |
|
644
|
16
|
|
|
|
|
18
|
for my $cap (@captured) { |
|
645
|
4
|
50
|
|
|
|
12
|
if (!eq_deeply($datam, $cap)) { |
|
646
|
|
|
|
|
|
|
# TODO push violation? |
|
647
|
0
|
|
|
|
|
0
|
next TOP; |
|
648
|
|
|
|
|
|
|
} |
|
649
|
|
|
|
|
|
|
} |
|
650
|
|
|
|
|
|
|
} |
|
651
|
|
|
|
|
|
|
|
|
652
|
24
|
|
|
|
|
10203
|
$captured_for_each_scope[$sub_depth] = $datam; |
|
653
|
|
|
|
|
|
|
} |
|
654
|
|
|
|
|
|
|
else { |
|
655
|
3
|
|
|
|
|
6
|
my $is_captured_at_before_and_op = 0; |
|
656
|
3
|
|
|
|
|
8
|
for my $b_regex (@regexs_at_before_and_op) { |
|
657
|
3
|
|
|
|
|
8
|
$class->_scan_regex($b_regex, $i); |
|
658
|
|
|
|
|
|
|
|
|
659
|
3
|
50
|
|
|
|
4
|
my %captured_this_scope = %{$captured_for_each_scope[$sub_depth] || {}}; |
|
|
3
|
|
|
|
|
12
|
|
|
660
|
3
|
50
|
|
|
|
6
|
if (%captured_this_scope) { |
|
661
|
3
|
|
|
|
|
3
|
$is_captured_at_before_and_op = 1; |
|
662
|
3
|
|
|
|
|
4
|
last; |
|
663
|
|
|
|
|
|
|
} |
|
664
|
|
|
|
|
|
|
} |
|
665
|
|
|
|
|
|
|
|
|
666
|
3
|
|
|
|
|
2
|
for my $a_regex (@regexs_at_after_and_op) { |
|
667
|
3
|
|
|
|
|
8
|
$class->_scan_regex($a_regex, $i); |
|
668
|
|
|
|
|
|
|
|
|
669
|
3
|
50
|
|
|
|
3
|
my %captured_this_scope = %{$captured_for_each_scope[$sub_depth] || {}}; |
|
|
3
|
|
|
|
|
9
|
|
|
670
|
3
|
50
|
33
|
|
|
14
|
if (%captured_this_scope && $is_captured_at_before_and_op) { |
|
671
|
3
|
|
|
|
|
4
|
last; |
|
672
|
|
|
|
|
|
|
} |
|
673
|
|
|
|
|
|
|
} |
|
674
|
|
|
|
|
|
|
} |
|
675
|
|
|
|
|
|
|
|
|
676
|
27
|
|
|
|
|
62
|
next; |
|
677
|
|
|
|
|
|
|
} |
|
678
|
|
|
|
|
|
|
|
|
679
|
1002
|
100
|
|
|
|
1155
|
if ($token_type == SPECIFIC_VALUE) { |
|
680
|
53
|
100
|
|
|
|
172
|
if ($token_data =~ /\A\$[0-9]+\Z/) { |
|
681
|
36
|
|
|
|
|
45
|
delete $captured_for_each_scope[$sub_depth]->{$token_data}; |
|
682
|
36
|
|
|
|
|
57
|
next; |
|
683
|
|
|
|
|
|
|
} |
|
684
|
|
|
|
|
|
|
|
|
685
|
17
|
100
|
100
|
|
|
74
|
if ($token_data eq '$+' || $token_data eq '$-') { |
|
686
|
|
|
|
|
|
|
# TODO duplicated... |
|
687
|
10
|
50
|
|
|
|
23
|
$token = $tokens->[$i+2] or next; |
|
688
|
10
|
|
|
|
|
11
|
$token_data = $token->{data}; |
|
689
|
10
|
100
|
|
|
|
28
|
if ($token_data =~ /\A -? [0-9]+ \Z/x) { |
|
690
|
6
|
100
|
|
|
|
16
|
$token_data-- if $token_data > 0; |
|
691
|
|
|
|
|
|
|
|
|
692
|
6
|
|
|
|
|
8
|
my @num_vars = sort {$a cmp $b} grep { $_ =~ /\A\$[0-9]+\Z/} keys %{$captured_for_each_scope[$sub_depth]}; |
|
|
0
|
|
|
|
|
0
|
|
|
|
2
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
14
|
|
|
693
|
|
|
|
|
|
|
|
|
694
|
6
|
100
|
|
|
|
14
|
if (my $hit = $num_vars[$token_data]) { |
|
695
|
2
|
|
|
|
|
4
|
delete $captured_for_each_scope[$sub_depth]->{$hit}; |
|
696
|
|
|
|
|
|
|
} |
|
697
|
|
|
|
|
|
|
} |
|
698
|
|
|
|
|
|
|
else { |
|
699
|
4
|
|
|
|
|
9
|
delete $captured_for_each_scope[$sub_depth]->{$token->{data}}; |
|
700
|
|
|
|
|
|
|
} |
|
701
|
|
|
|
|
|
|
} |
|
702
|
|
|
|
|
|
|
|
|
703
|
17
|
|
|
|
|
35
|
next; |
|
704
|
|
|
|
|
|
|
} |
|
705
|
|
|
|
|
|
|
|
|
706
|
949
|
100
|
|
|
|
1057
|
if ($is_used_english) { |
|
707
|
71
|
100
|
100
|
|
|
175
|
if ($token_type == GLOBAL_VAR || $token_type == VAR) { |
|
708
|
|
|
|
|
|
|
# TODO duplicated... |
|
709
|
7
|
50
|
100
|
|
|
32
|
if ( |
|
|
|
|
66
|
|
|
|
|
|
710
|
|
|
|
|
|
|
$token_data eq '$LAST_PAREN_MATCH' || |
|
711
|
|
|
|
|
|
|
$token_data eq '$LAST_MATCH_END' || |
|
712
|
|
|
|
|
|
|
$token_data eq '$LAST_MATCH_START' |
|
713
|
|
|
|
|
|
|
) { |
|
714
|
7
|
50
|
|
|
|
15
|
$token = $tokens->[$i+2] or next; |
|
715
|
7
|
|
|
|
|
7
|
$token_data = $token->{data}; |
|
716
|
7
|
100
|
|
|
|
23
|
if ($token_data =~ /\A -? [0-9]+ \Z/x) { |
|
717
|
6
|
100
|
|
|
|
13
|
$token_data-- if $token_data > 0; |
|
718
|
|
|
|
|
|
|
|
|
719
|
6
|
|
|
|
|
5
|
my @num_vars = sort {$a cmp $b} grep { $_ =~ /\A\$[0-9]+\Z/} keys %{$captured_for_each_scope[$sub_depth]}; |
|
|
0
|
|
|
|
|
0
|
|
|
|
2
|
|
|
|
|
8
|
|
|
|
6
|
|
|
|
|
14
|
|
|
720
|
|
|
|
|
|
|
|
|
721
|
6
|
100
|
|
|
|
13
|
if (my $hit = $num_vars[$token_data]) { |
|
722
|
2
|
|
|
|
|
5
|
delete $captured_for_each_scope[$sub_depth]->{$hit}; |
|
723
|
|
|
|
|
|
|
} |
|
724
|
|
|
|
|
|
|
} |
|
725
|
|
|
|
|
|
|
else { |
|
726
|
1
|
|
|
|
|
3
|
delete $captured_for_each_scope[$sub_depth]->{$token->{data}}; |
|
727
|
|
|
|
|
|
|
} |
|
728
|
|
|
|
|
|
|
} |
|
729
|
|
|
|
|
|
|
} |
|
730
|
|
|
|
|
|
|
} |
|
731
|
|
|
|
|
|
|
|
|
732
|
949
|
100
|
|
|
|
1045
|
if ($token_type == FUNCTION_DECL) { |
|
733
|
5
|
|
|
|
|
11
|
$depth_for_each_subs{$lbnum_for_scope} = 1; |
|
734
|
5
|
|
|
|
|
3
|
$assign_ctx = 'NONE'; # XXX Umm... |
|
735
|
5
|
|
|
|
|
6
|
$sub_depth++; |
|
736
|
5
|
|
|
|
|
5
|
$captured_for_each_scope[$sub_depth] = {}; |
|
737
|
5
|
|
|
|
|
10
|
next; |
|
738
|
|
|
|
|
|
|
} |
|
739
|
|
|
|
|
|
|
|
|
740
|
944
|
100
|
|
|
|
1135
|
if ($token_type == LEFT_BRACE) { |
|
741
|
50
|
|
|
|
|
32
|
$lbnum_for_scope++; |
|
742
|
50
|
|
|
|
|
84
|
next; |
|
743
|
|
|
|
|
|
|
} |
|
744
|
|
|
|
|
|
|
|
|
745
|
894
|
100
|
|
|
|
1728
|
if ($token_type == RIGHT_BRACE) { |
|
746
|
53
|
|
|
|
|
38
|
$lbnum_for_scope--; |
|
747
|
53
|
100
|
|
|
|
78
|
if (delete $depth_for_each_subs{$lbnum_for_scope}) { |
|
748
|
5
|
|
|
|
|
6
|
my $regexp_in_return_ctx; |
|
749
|
5
|
50
|
|
|
|
10
|
if ($token = $tokens->[$i-2]) { |
|
750
|
5
|
50
|
|
|
|
16
|
if ($token->{type} == REG_EXP) { |
|
|
|
50
|
|
|
|
|
|
|
751
|
0
|
|
|
|
|
0
|
$regexp_in_return_ctx = $token; |
|
752
|
|
|
|
|
|
|
} |
|
753
|
|
|
|
|
|
|
elsif ($token = $tokens->[$i-3]) { |
|
754
|
5
|
100
|
|
|
|
9
|
if ($token->{type} == REG_EXP) { |
|
755
|
3
|
|
|
|
|
6
|
$regexp_in_return_ctx = $token; |
|
756
|
|
|
|
|
|
|
} |
|
757
|
|
|
|
|
|
|
} |
|
758
|
|
|
|
|
|
|
} |
|
759
|
|
|
|
|
|
|
|
|
760
|
5
|
|
|
|
|
6
|
my $captured = pop @captured_for_each_scope; |
|
761
|
5
|
50
|
33
|
|
|
12
|
if (defined $captured and my %captured = %{$captured}) { |
|
|
5
|
|
|
|
|
26
|
|
|
762
|
5
|
100
|
|
|
|
9
|
if ($regexp_in_return_ctx) { |
|
763
|
|
|
|
|
|
|
# should check equality between to just before regexp token? |
|
764
|
3
|
100
|
|
3
|
|
19
|
if (all {substr($_, 0, 1) eq q<$>} keys %captured) { |
|
|
3
|
|
|
|
|
9
|
|
|
765
|
2
|
|
|
|
|
11
|
next; |
|
766
|
|
|
|
|
|
|
} |
|
767
|
|
|
|
|
|
|
} |
|
768
|
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
push @violations, { |
|
770
|
|
|
|
|
|
|
filename => $file, |
|
771
|
|
|
|
|
|
|
line => $just_before_regex_token->{line}, |
|
772
|
3
|
|
|
|
|
14
|
description => DESC, |
|
773
|
|
|
|
|
|
|
explanation => EXPL, |
|
774
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
775
|
|
|
|
|
|
|
}; |
|
776
|
|
|
|
|
|
|
} |
|
777
|
|
|
|
|
|
|
} |
|
778
|
51
|
|
|
|
|
88
|
next; |
|
779
|
|
|
|
|
|
|
} |
|
780
|
|
|
|
|
|
|
} |
|
781
|
|
|
|
|
|
|
|
|
782
|
49
|
100
|
|
|
|
26
|
if (%{$captured_for_each_scope[-1] || {}}) { |
|
|
49
|
100
|
|
|
|
140
|
|
|
783
|
|
|
|
|
|
|
push @violations, { |
|
784
|
|
|
|
|
|
|
filename => $file, |
|
785
|
|
|
|
|
|
|
line => $just_before_regex_token->{line}, |
|
786
|
8
|
|
|
|
|
30
|
description => DESC, |
|
787
|
|
|
|
|
|
|
explanation => EXPL, |
|
788
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
789
|
|
|
|
|
|
|
}; |
|
790
|
|
|
|
|
|
|
} |
|
791
|
|
|
|
|
|
|
|
|
792
|
49
|
|
|
|
|
210
|
return \@violations; |
|
793
|
|
|
|
|
|
|
} |
|
794
|
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
sub _scan_regex { |
|
796
|
26
|
|
|
26
|
|
24
|
my ($class, $token, $i) = @_; |
|
797
|
|
|
|
|
|
|
|
|
798
|
26
|
100
|
|
|
|
34
|
my $line_num = defined $just_before_regex_token ? $just_before_regex_token->{line} : 1; |
|
799
|
26
|
|
|
|
|
22
|
my $captured = $captured_for_each_scope[$sub_depth]; |
|
800
|
26
|
100
|
66
|
|
|
92
|
if (defined $captured && %$captured) { |
|
801
|
5
|
|
|
|
|
17
|
push @violations, { |
|
802
|
|
|
|
|
|
|
filename => $file, |
|
803
|
|
|
|
|
|
|
line => $line_num, |
|
804
|
|
|
|
|
|
|
description => DESC, |
|
805
|
|
|
|
|
|
|
explanation => EXPL, |
|
806
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
807
|
|
|
|
|
|
|
}; |
|
808
|
|
|
|
|
|
|
} |
|
809
|
|
|
|
|
|
|
|
|
810
|
26
|
|
|
|
|
27
|
$captured_for_each_scope[$sub_depth] = {}; |
|
811
|
26
|
|
|
|
|
20
|
$just_before_regex_token = $token; |
|
812
|
|
|
|
|
|
|
|
|
813
|
26
|
|
|
|
|
28
|
my $token_data = $token->{data}; |
|
814
|
|
|
|
|
|
|
|
|
815
|
26
|
|
|
|
|
55
|
my @re_chars = split //, $token_data; |
|
816
|
|
|
|
|
|
|
|
|
817
|
26
|
|
|
|
|
22
|
my $escaped = 0; |
|
818
|
26
|
|
|
|
|
15
|
my $lbnum = 0; |
|
819
|
26
|
|
|
|
|
22
|
my $captured_num = 0; |
|
820
|
26
|
|
|
|
|
40
|
for (my $j = 0; my $re_char = $re_chars[$j]; $j++) { |
|
821
|
133
|
50
|
|
|
|
139
|
if ($escaped) { |
|
822
|
0
|
0
|
|
|
|
0
|
if ($re_char =~ /[0-9]/) { |
|
823
|
|
|
|
|
|
|
# TODO should track follows number |
|
824
|
0
|
|
|
|
|
0
|
delete $captured_for_each_scope[$sub_depth]->{q<$> . $re_char}; |
|
825
|
|
|
|
|
|
|
} |
|
826
|
0
|
|
|
|
|
0
|
$escaped = 0; |
|
827
|
0
|
|
|
|
|
0
|
return; |
|
828
|
|
|
|
|
|
|
} |
|
829
|
|
|
|
|
|
|
|
|
830
|
133
|
100
|
|
|
|
146
|
if ($re_char eq '\\') { |
|
831
|
1
|
|
|
|
|
1
|
$escaped = 1; |
|
832
|
1
|
|
|
|
|
4
|
return; |
|
833
|
|
|
|
|
|
|
} |
|
834
|
|
|
|
|
|
|
|
|
835
|
132
|
50
|
|
|
|
150
|
if ($re_char eq '[') { |
|
836
|
0
|
|
|
|
|
0
|
$lbnum++; |
|
837
|
0
|
|
|
|
|
0
|
return; |
|
838
|
|
|
|
|
|
|
} |
|
839
|
|
|
|
|
|
|
|
|
840
|
132
|
50
|
|
|
|
141
|
if ($lbnum > 0) { # in [...] |
|
841
|
0
|
0
|
|
|
|
0
|
if ($re_char eq ']') { |
|
842
|
0
|
|
|
|
|
0
|
$lbnum--; |
|
843
|
0
|
|
|
|
|
0
|
return; |
|
844
|
|
|
|
|
|
|
} |
|
845
|
|
|
|
|
|
|
|
|
846
|
0
|
|
|
|
|
0
|
return; |
|
847
|
|
|
|
|
|
|
} |
|
848
|
|
|
|
|
|
|
|
|
849
|
132
|
100
|
|
|
|
217
|
if ($re_char eq '(') { |
|
850
|
31
|
|
|
|
|
25
|
my $captured_name = ''; |
|
851
|
|
|
|
|
|
|
|
|
852
|
31
|
100
|
33
|
|
|
91
|
if ($re_chars[$j+1] eq '?') { |
|
|
|
50
|
|
|
|
|
|
|
853
|
1
|
|
|
|
|
3
|
my $delimiter = $re_chars[$j+2]; |
|
854
|
|
|
|
|
|
|
|
|
855
|
1
|
50
|
|
|
|
3
|
if ($delimiter eq ':') { |
|
856
|
0
|
|
|
|
|
0
|
return; |
|
857
|
|
|
|
|
|
|
} |
|
858
|
|
|
|
|
|
|
|
|
859
|
1
|
50
|
|
|
|
3
|
if ($delimiter eq 'P') { |
|
860
|
0
|
|
|
|
|
0
|
$delimiter = $re_chars[$j+3]; |
|
861
|
0
|
|
|
|
|
0
|
$j++; |
|
862
|
|
|
|
|
|
|
} |
|
863
|
|
|
|
|
|
|
|
|
864
|
1
|
50
|
33
|
|
|
15
|
if ($delimiter eq '<' || $delimiter eq q{'}) { |
|
865
|
1
|
|
|
|
|
6
|
for ($j += 3; $re_char = $re_chars[$j]; $j++) { |
|
866
|
4
|
100
|
66
|
|
|
19
|
if ( |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
867
|
|
|
|
|
|
|
($delimiter eq '<' && $re_char eq '>') || |
|
868
|
|
|
|
|
|
|
($delimiter eq q{'} && $re_char eq q{'}) |
|
869
|
|
|
|
|
|
|
) { |
|
870
|
1
|
|
|
|
|
2
|
last; |
|
871
|
|
|
|
|
|
|
} |
|
872
|
3
|
|
|
|
|
6
|
$captured_name .= $re_char; |
|
873
|
|
|
|
|
|
|
} |
|
874
|
|
|
|
|
|
|
|
|
875
|
1
|
50
|
|
|
|
3
|
if ($reg_not_ctx) { |
|
876
|
|
|
|
|
|
|
push @violations, { |
|
877
|
|
|
|
|
|
|
filename => $file, |
|
878
|
|
|
|
|
|
|
line => $token->{line}, |
|
879
|
0
|
|
|
|
|
0
|
description => DESC, |
|
880
|
|
|
|
|
|
|
explanation => EXPL, |
|
881
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
882
|
|
|
|
|
|
|
}; |
|
883
|
|
|
|
|
|
|
} |
|
884
|
|
|
|
|
|
|
else { |
|
885
|
1
|
|
|
|
|
2
|
$captured_num++; |
|
886
|
1
|
|
|
|
|
4
|
$captured_for_each_scope[$sub_depth]->{$captured_name} = 1; |
|
887
|
|
|
|
|
|
|
} |
|
888
|
|
|
|
|
|
|
} |
|
889
|
|
|
|
|
|
|
} |
|
890
|
|
|
|
|
|
|
elsif ($re_chars[$j+1] ne '?' || $re_chars[$j+2] ne ':') { |
|
891
|
30
|
50
|
|
|
|
31
|
if ($reg_not_ctx) { |
|
892
|
|
|
|
|
|
|
push @violations, { |
|
893
|
|
|
|
|
|
|
filename => $file, |
|
894
|
|
|
|
|
|
|
line => $token->{line}, |
|
895
|
0
|
|
|
|
|
0
|
description => DESC, |
|
896
|
|
|
|
|
|
|
explanation => EXPL, |
|
897
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
898
|
|
|
|
|
|
|
}; |
|
899
|
|
|
|
|
|
|
} |
|
900
|
|
|
|
|
|
|
else { |
|
901
|
30
|
|
|
|
|
21
|
$captured_num++; |
|
902
|
30
|
|
|
|
|
92
|
$captured_for_each_scope[$sub_depth]->{q<$> . $captured_num} = 1; |
|
903
|
|
|
|
|
|
|
} |
|
904
|
|
|
|
|
|
|
} |
|
905
|
|
|
|
|
|
|
} |
|
906
|
|
|
|
|
|
|
} |
|
907
|
|
|
|
|
|
|
|
|
908
|
25
|
50
|
|
|
|
34
|
if ($assign_ctx ne 'NONE') { |
|
909
|
0
|
|
|
|
|
0
|
my $captured = $captured_for_each_scope[$sub_depth]; |
|
910
|
|
|
|
|
|
|
|
|
911
|
0
|
0
|
|
|
|
0
|
if ($assign_ctx eq 'UNLIMITED_ARRAY') { |
|
912
|
0
|
0
|
|
|
|
0
|
if (%{$captured || {}}) { |
|
|
0
|
0
|
|
|
|
0
|
|
|
913
|
0
|
0
|
|
0
|
|
0
|
if (all {substr($_, 0, 1) eq q<$> } keys %$captured) { |
|
|
0
|
|
|
|
|
0
|
|
|
914
|
0
|
|
|
|
|
0
|
$captured_for_each_scope[$sub_depth] = {}; |
|
915
|
|
|
|
|
|
|
} |
|
916
|
|
|
|
|
|
|
} |
|
917
|
0
|
|
|
|
|
0
|
return; |
|
918
|
|
|
|
|
|
|
} |
|
919
|
|
|
|
|
|
|
|
|
920
|
0
|
|
|
|
|
0
|
$captured_for_each_scope[$sub_depth] = {}; |
|
921
|
|
|
|
|
|
|
|
|
922
|
0
|
0
|
|
|
|
0
|
my $maybe_reg_opt = $tokens->[$i+2] or return; |
|
923
|
0
|
0
|
|
|
|
0
|
if ($maybe_reg_opt->{type} == REG_OPT) { |
|
924
|
0
|
0
|
0
|
|
|
0
|
if ($assign_ctx ne 'UNLIMITED' && $maybe_reg_opt->{data} =~ /g/) { |
|
925
|
|
|
|
|
|
|
push @violations, { |
|
926
|
|
|
|
|
|
|
filename => $file, |
|
927
|
|
|
|
|
|
|
line => $token->{line}, |
|
928
|
0
|
|
|
|
|
0
|
description => DESC, |
|
929
|
|
|
|
|
|
|
explanation => EXPL, |
|
930
|
|
|
|
|
|
|
policy => __PACKAGE__, |
|
931
|
|
|
|
|
|
|
}; |
|
932
|
|
|
|
|
|
|
} |
|
933
|
|
|
|
|
|
|
} |
|
934
|
|
|
|
|
|
|
|
|
935
|
0
|
|
|
|
|
0
|
return; |
|
936
|
|
|
|
|
|
|
} |
|
937
|
|
|
|
|
|
|
|
|
938
|
25
|
|
|
|
|
21
|
$reg_not_ctx = 0; |
|
939
|
|
|
|
|
|
|
|
|
940
|
25
|
|
|
|
|
41
|
return; |
|
941
|
|
|
|
|
|
|
} |
|
942
|
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
1; |
|
944
|
|
|
|
|
|
|
|