Perl/Lint/Policy/ControlStructures/ProhibitMutatingListFunctions.pm

filter: Statementstmt 11.7% 19 / 162 Branchbran 0.0% 0 / 154 Conditioncond 0.0% 0 / 63 MC/DCmcdc 0.0% 0 / 40 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 5.6% 24 / 426 CC 101 SCAR 91.9
CC
101
Cov
5%
evaluate
10302.0
BEGIN
1.0
BEGIN
1.0
CRAP 9816.1
« Perl/Lint/Policy/RegularExpressions/ProhibitUnusedCapture.pm ↑ Summary Perl/Lint/Policy/Variables/ProhibitPackageVars.pm »
1 package Perl::Lint::Policy::ControlStructures::ProhibitMutatingListFunctions;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Perl::Lint::Constants::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use parent "Perl::Lint::Policy";
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 DESC => q{Don't modify $_ in list functions},
9 EXPL => [114],
10 2 };
11  
12 2 my %_target_functions = (
13 map => 1,
14 grep => 1,
15 first => 1,
16 any => 1,
17 all => 1,
18 none => 1,
19 notall => 1,
20 true => 1,
21 false => 1,
22 firstidx => 1,
23 first_index => 1,
24 lastidx => 1,
25 last_index => 1,
26 insert_after => 1,
27 insert_after_string => 1,
28 );
29  
30 2 my %assigner = (
31 &ASSIGN => 1,
32 &POWER_EQUAL => 1,
33 &ADD_EQUAL => 1,
34 &MUL_EQUAL => 1,
35 &AND_BIT_EQUAL => 1,
36 &SUB_EQUAL => 1,
37 &DIV_EQUAL => 1,
38 &OR_BIT_EQUAL => 1,
39 &MOD_EQUAL => 1,
40 &NOT_BIT_EQUAL => 1,
41 &DEFAULT_EQUAL => 1,
42 &AND_EQUAL => 1,
43 &OR_EQUAL => 1,
44 &STRING_ADD_EQUAL => 1,
45 &LEFT_SHIFT_EQUAL => 1,
46 &RIGHT_SHIFT_EQUAL => 1,
47 );
48  
49 2 my %reg_replace_token_types = (
50 &REG_REPLACE => 1,
51 &REG_ALL_REPLACE => 1,
52 );
53  
54 0 ▶sub evaluate {
Subroutine evaluate: not called CC=101 SCAR=92.4
Pod undocumented
55 0 my ($class, $file, $tokens, $src, $args) = @_;
56  
57 0 my %target_functions = %_target_functions;
58 0 ▶ if (my $this_policies_arg = $args->{prohibit_mutating_list_functions}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $this_policies_arg = $args->{"prohibit_mutating_list_functions"}) 0 0 0
59 0 ▶ if (my $list_funcs = $this_policies_arg->{list_funcs}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $list_funcs = $this_policies_arg->{"list_funcs"}) 0 0 0
60 0 %target_functions = ();
61 0 $target_functions{$_} = 1 for split /\s+/, $list_funcs;
62 }
63  
64 0 ▶ if (my $add_list_funcs = $this_policies_arg->{add_list_funcs}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $add_list_funcs = $this_policies_arg->{"add_list_funcs"}) 0 0 0
65 0 $target_functions{$_} = 1 for split /\s+/, $add_list_funcs;
66 }
67 }
68  
69 0 my @violations;
70 # use Data::Dumper::Concise; warn Dumper($tokens); # TODO remove
71 0 ▶ for (my $i = 0, my $token_type, my $token_data; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
72 0 $token_type = $token->{type};
73 0 $token_data = $token->{data};
74  
75 0 ▶ if ($token_type == BUILTIN_FUNC || $token_type == KEY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 70 or $token_type == 122) 0 0 0
Condition0%0/3
$token_type == 70 or $token_type == 122
l!l&&r!l&&!r
000
MC/DC0%0/2
$token_type == 70 or $token_type == 122
$token_type == 70 $token_type == 122
Truth table0%0/3
A or B
A= $token_type == 70B= $token_type == 122
ABresult
1X1
011
000
76 0 ▶ if ($target_functions{$token_data}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($target_functions{$token_data}) 0 0 0
77 0 ▶ $token = $tokens->[++$i] or last;
Branch: 1 branch
BranchTrueFalseTotal
$token = $$tokens[++$i] or last 0 0 0
78 0 ▶ if ($token->{type} != LEFT_BRACE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} != 109) 0 0 0
79 0 next;
80 }
81  
82 0 my $lbnum = 1;
83 0 ▶ for ($i++; $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $tokens->[$i]) 0 0 0
84 0 $token_type = $token->{type};
85 0 $token_data = $token->{data};
86  
87 0 ▶ if ($token_type == LEFT_BRACE) {
Branch: 6 branches
BranchTrueFalseTotal
if ($token_type == 109) { } 0 0 0
elsif ($token_type == 110) { } 0 0 0
elsif ($token_type == 137 and $token_data eq '$_') { } 0 0 0
elsif ($token_type == 45 or $token_type == 46) { } 0 0 0
elsif ($reg_replace_token_types{$token_type}) { } 0 0 0
elsif ($token_type == 122 or $token_type == 70 or $token_type == 207) { } 0 0 0
88 0 $lbnum++;
89 }
90 elsif ($token_type == RIGHT_BRACE) {
91 0 ▶ last if --$lbnum <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if --$lbnum <= 0 0 0 0
92 }
93 ▶ elsif ($token_type == SPECIFIC_VALUE && $token_data eq '$_') {
Condition0%0/3
$token_type == 137 and $token_data eq "\$_"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 137 and $token_data eq "\$_"
$token_type == 137 $token_data eq "\$_"
Truth table0%0/3
A and B
A= $token_type == 137B= $token_data eq "\$_"
ABresult
0X0
100
111
94 0 ▶ $token = $tokens->[++$i] or last;
Branch: 1 branch
BranchTrueFalseTotal
$token = $$tokens[++$i] or last 0 0 0
95 0 $token_type = $token->{type};
96  
97 0 ▶ if ($token_type == RIGHT_BRACE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 110) 0 0 0
98 0 ▶ last if --$lbnum <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if --$lbnum <= 0 0 0 0
99 }
100  
101 # for assign
102 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($assigner{$token_type} or $token_type == 45 or $token_type == 46) 0 0 0
Condition0%0/6
$assigner{$token_type} or $token_type == 45 or $token_type == 46
l!l&&r!l&&!r
000
$assigner{$token_type} or $token_type == 45
l!l&&r!l&&!r
000
MC/DC0%0/3
$assigner{$token_type} or $token_type == 45 or $token_type == 46
$assigner{$token_type} $token_type == 45 $token_type == 46
Truth table0%0/4
A or B or C
A= $assigner{$token_type}B= $token_type == 45C= $token_type == 46
ABCresult
1XX1
01X1
0011
0000
103 $assigner{$token_type} ||
104 $token_type == PLUSPLUS || $token_type == MINUSMINUS
105 ) {
106 push @violations, {
107 filename => $file,
108 line => $token->{line},
109 0 description => DESC,
110 explanation => EXPL,
111 policy => __PACKAGE__,
112 };
113 0 last;
114 }
115  
116 # for replace by regex
117 0 ▶ if ($token_type == REG_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 35) 0 0 0
118 0 ▶ $token = $tokens->[++$i] or last;
Branch: 1 branch
BranchTrueFalseTotal
$token = $$tokens[++$i] or last 0 0 0
119 0 $token_type = $token->{type};
120  
121 0 ▶ if ($reg_replace_token_types{$token_type}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reg_replace_token_types{$token_type}) 0 0 0
122 0 my $is_replace_to_empty = 0;
123 0 my $is_equal_src_between_dst = 0;
124  
125 0 my $replace_to;
126 my $replace_from;
127 0 ▶ for ($i++; $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $tokens->[$i]) 0 0 0
128 0 $token_type = $token->{type};
129 0 ▶ if ($token_type == REG_REPLACE_FROM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 156) { } 0 0 0
elsif ($token_type == 157) { } 0 0 0
130 0 $replace_from = $token->{data};
131 }
132 elsif ($token_type == REG_REPLACE_TO) {
133 0 $replace_to = $token->{data};
134 0 ▶ if ($replace_to eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($replace_to eq '') { } 0 0 0
elsif ($replace_to eq $replace_from) { } 0 0 0
135 0 $is_replace_to_empty = 1;
136 }
137 elsif ($replace_to eq $replace_from) {
138 0 $is_equal_src_between_dst =1;
139 }
140 0 $i++; # at last reg delim
141 0 last;
142 }
143 }
144  
145 0 ▶ my $is_replaced = !$is_replace_to_empty && !$is_equal_src_between_dst;
Condition0%0/3
$is_replace_to_empty || $is_equal_src_between_dst
l!l&&r!l&&!r
000
MC/DC0%0/2
$is_replace_to_empty || $is_equal_src_between_dst
$is_replace_to_empty $is_equal_src_between_dst
Truth table0%0/3
A || B
A= $is_replace_to_emptyB= $is_equal_src_between_dst
ABresult
1X1
011
000
146 0 ▶ if ($token = $tokens->[++$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $$tokens[++$i]) 0 0 0
147 0 ▶ if ($token->{type} == REG_OPT and my @opts = $token->{data} =~ /([cdrs])/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 144 and my(@opts) = $token->{"data"} =~ /([cdrs])/g) 0 0 0
Condition0%0/3
$token->{"type"} == 144 and my(@opts) = $token->{"data"} =~ /([cdrs])/g
!ll&&!rl&&r
000
MC/DC0%0/2
$token->{"type"} == 144 and my(@opts) = $token->{"data"} =~ /([cdrs])/g
$token->{"type"} == 144 my(@opts) = $token->{"data"} =~ /([cdrs])/g
Truth table0%0/3
A and B
A= $token->{"type"} == 144B= my(@opts) = $token->{"data"} =~ /([cdrs])/g
ABresult
0X0
100
111
148 0 my %opts = map {$_ => 1} @opts;
149  
150 0 ▶ if ($opts{r}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{'r'}) { } 0 0 0
151 0 $is_replaced = 0;
152 }
153 else {
154 0 ▶ if ($opts{c}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"c"}) 0 0 0
155 0 $is_replaced = $is_equal_src_between_dst;
156 }
157  
158 0 ▶ if ($opts{d}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"d"}) 0 0 0
159 0 $is_replaced = $is_replace_to_empty;
160 }
161  
162 0 ▶ if ($opts{s}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"s"}) 0 0 0
163 0 ▶ $is_replaced = $is_replace_to_empty || $is_equal_src_between_dst;
Condition0%0/3
$is_replace_to_empty || $is_equal_src_between_dst
l!l&&r!l&&!r
000
MC/DC0%0/2
$is_replace_to_empty || $is_equal_src_between_dst
$is_replace_to_empty $is_equal_src_between_dst
Truth table0%0/3
A || B
A= $is_replace_to_emptyB= $is_equal_src_between_dst
ABresult
1X1
011
000
164 }
165 }
166 }
167 }
168  
169 0 ▶ if (!$is_replaced) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_replaced) 0 0 0
170 0 last;
171 }
172  
173 push @violations, {
174 filename => $file,
175 line => $token->{line},
176 0 description => DESC,
177 explanation => EXPL,
178 policy => __PACKAGE__,
179 };
180 0 last;
181 }
182 }
183 }
184 ▶ elsif ($token_type == PLUSPLUS || $token_type == MINUSMINUS) {
Condition0%0/3
$token_type == 45 or $token_type == 46
l!l&&r!l&&!r
000
MC/DC0%0/2
$token_type == 45 or $token_type == 46
$token_type == 45 $token_type == 46
Truth table0%0/3
A or B
A= $token_type == 45B= $token_type == 46
ABresult
1X1
011
000
185 0 ▶ $token = $tokens->[++$i] or last;
Branch: 1 branch
BranchTrueFalseTotal
$token = $$tokens[++$i] or last 0 0 0
186 0 ▶ if ($token->{type} == SPECIFIC_VALUE && $token->{data} eq '$_') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 137 and $token->{"data"} eq "\$_") 0 0 0
Condition0%0/3
$token->{"type"} == 137 and $token->{"data"} eq "\$_"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->{"type"} == 137 and $token->{"data"} eq "\$_"
$token->{"type"} == 137 $token->{"data"} eq "\$_"
Truth table0%0/3
A and B
A= $token->{"type"} == 137B= $token->{"data"} eq "\$_"
ABresult
0X0
100
111
187 push @violations, {
188 filename => $file,
189 line => $token->{line},
190 0 description => DESC,
191 explanation => EXPL,
192 policy => __PACKAGE__,
193 };
194 0 last;
195 }
196 }
197 elsif ($reg_replace_token_types{$token_type}) {
198 0 ▶ my $before_token = $tokens->[$i-1] or next;
Branch: 1 branch
BranchTrueFalseTotal
my $before_token = $$tokens[$i - 1] or next 0 0 0
199 0 ▶ if ($before_token->{type} != REG_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if ($before_token->{"type"} != 35) 0 0 0
200 0 my $is_replace_to_empty = 0;
201 0 my $is_equal_src_between_dst = 0;
202  
203 0 my $replace_to;
204 my $replace_from;
205 0 ▶ for ($i++; $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $tokens->[$i]) 0 0 0
206 0 $token_type = $token->{type};
207 0 ▶ if ($token_type == REG_REPLACE_FROM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 156) { } 0 0 0
elsif ($token_type == 157) { } 0 0 0
208 0 $replace_from = $token->{data};
209 }
210 elsif ($token_type == REG_REPLACE_TO) {
211 0 $replace_to = $token->{data};
212 0 ▶ if ($replace_to eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($replace_to eq '') { } 0 0 0
elsif ($replace_to eq $replace_from) { } 0 0 0
213 0 $is_replace_to_empty = 1;
214 }
215 elsif ($replace_to eq $replace_from) {
216 0 $is_equal_src_between_dst =1;
217 }
218 0 $i++; # at last reg delim
219 0 last;
220 }
221 }
222  
223 0 ▶ my $is_replaced = !$is_replace_to_empty && !$is_equal_src_between_dst;
Condition0%0/3
$is_replace_to_empty || $is_equal_src_between_dst
l!l&&r!l&&!r
000
MC/DC0%0/2
$is_replace_to_empty || $is_equal_src_between_dst
$is_replace_to_empty $is_equal_src_between_dst
Truth table0%0/3
A || B
A= $is_replace_to_emptyB= $is_equal_src_between_dst
ABresult
1X1
011
000
224 0 ▶ if ($token = $tokens->[++$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $$tokens[++$i]) 0 0 0
225 0 ▶ if ($token->{type} == REG_OPT and my @opts = $token->{data} =~ /([cdrs])/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 144 and my(@opts) = $token->{"data"} =~ /([cdrs])/g) 0 0 0
Condition0%0/3
$token->{"type"} == 144 and my(@opts) = $token->{"data"} =~ /([cdrs])/g
!ll&&!rl&&r
000
MC/DC0%0/2
$token->{"type"} == 144 and my(@opts) = $token->{"data"} =~ /([cdrs])/g
$token->{"type"} == 144 my(@opts) = $token->{"data"} =~ /([cdrs])/g
Truth table0%0/3
A and B
A= $token->{"type"} == 144B= my(@opts) = $token->{"data"} =~ /([cdrs])/g
ABresult
0X0
100
111
226 0 my %opts = map {$_ => 1} @opts;
227  
228 0 ▶ if ($opts{r}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{'r'}) { } 0 0 0
229 0 $is_replaced = 0;
230 }
231 else {
232 0 ▶ if ($opts{c}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"c"}) 0 0 0
233 0 $is_replaced = $is_equal_src_between_dst;
234 }
235  
236 0 ▶ if ($opts{d}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"d"}) 0 0 0
237 0 $is_replaced = $is_replace_to_empty;
238 }
239  
240 0 ▶ if ($opts{s}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"s"}) 0 0 0
241 0 ▶ $is_replaced = $is_replace_to_empty || $is_equal_src_between_dst;
Condition0%0/3
$is_replace_to_empty || $is_equal_src_between_dst
l!l&&r!l&&!r
000
MC/DC0%0/2
$is_replace_to_empty || $is_equal_src_between_dst
$is_replace_to_empty $is_equal_src_between_dst
Truth table0%0/3
A || B
A= $is_replace_to_emptyB= $is_equal_src_between_dst
ABresult
1X1
011
000
242 }
243 }
244 }
245 }
246  
247 0 ▶ if (!$is_replaced) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_replaced) 0 0 0
248 0 last;
249 }
250  
251 push @violations, {
252 filename => $file,
253 line => $token->{line},
254 0 description => DESC,
255 explanation => EXPL,
256 policy => __PACKAGE__,
257 };
258 0 last;
259 }
260 }
261 ▶ elsif ($token_type == KEY || $token_type == BUILTIN_FUNC || $token_type == DEFAULT) {
Condition0%0/6
$token_type == 122 or $token_type == 70 or $token_type == 207
l!l&&r!l&&!r
000
$token_type == 122 or $token_type == 70
l!l&&r!l&&!r
000
MC/DC0%0/3
$token_type == 122 or $token_type == 70 or $token_type == 207
$token_type == 122 $token_type == 70 $token_type == 207
Truth table0%0/4
A or B or C
A= $token_type == 122B= $token_type == 70C= $token_type == 207
ABCresult
1XX1
01X1
0011
0000
262 0 ▶ if ($token_data eq 'chop' || $token_data eq 'chomp') {
Branch: 3 branches
BranchTrueFalseTotal
if ($token_data eq 'chop' or $token_data eq 'chomp') { } 0 0 0
elsif ($token_data eq 'undef') { } 0 0 0
elsif ($token_data eq 'substr') { } 0 0 0
Condition0%0/3
$token_data eq "chop" or $token_data eq "chomp"
l!l&&r!l&&!r
000
MC/DC0%0/2
$token_data eq "chop" or $token_data eq "chomp"
$token_data eq "chop" $token_data eq "chomp"
Truth table0%0/3
A or B
A= $token_data eq "chop"B= $token_data eq "chomp"
ABresult
1X1
011
000
263 0 ▶ $token = $tokens->[++$i] or last;
Branch: 1 branch
BranchTrueFalseTotal
$token = $$tokens[++$i] or last 0 0 0
264 0 $token_type = $token->{type};
265 0 $token_data = $token->{data};
266 0 ▶ if ($token_type == SEMI_COLON || $token_type == RIGHT_BRACE) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token_type == 106 or $token_type == 110) { } 0 0 0
elsif ($token_type == 137 and $token_data eq '$_') { } 0 0 0
elsif ($token_type == 107) { } 0 0 0
Condition0%0/3
$token_type == 106 or $token_type == 110
l!l&&r!l&&!r
000
MC/DC0%0/2
$token_type == 106 or $token_type == 110
$token_type == 106 $token_type == 110
Truth table0%0/3
A or B
A= $token_type == 106B= $token_type == 110
ABresult
1X1
011
000
267 push @violations, {
268 filename => $file,
269 line => $token->{line},
270 0 description => DESC,
271 explanation => EXPL,
272 policy => __PACKAGE__,
273 };
274 0 last;
275 }
276 ▶ elsif ($token_type == SPECIFIC_VALUE && $token_data eq '$_') {
Condition0%0/3
$token_type == 137 and $token_data eq "\$_"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 137 and $token_data eq "\$_"
$token_type == 137 $token_data eq "\$_"
Truth table0%0/3
A and B
A= $token_type == 137B= $token_data eq "\$_"
ABresult
0X0
100
111
277 push @violations, {
278 filename => $file,
279 line => $token->{line},
280 0 description => DESC,
281 explanation => EXPL,
282 policy => __PACKAGE__,
283 };
284 0 last;
285 }
286 elsif ($token_type == LEFT_PAREN) {
287 0 ▶ $token = $tokens->[++$i] or last;
Branch: 1 branch
BranchTrueFalseTotal
$token = $$tokens[++$i] or last 0 0 0
288 0 ▶ if ($token->{type} == RIGHT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 108) 0 0 0
289 push @violations, {
290 filename => $file,
291 line => $token->{line},
292 0 description => DESC,
293 explanation => EXPL,
294 policy => __PACKAGE__,
295 };
296 0 last;
297 }
298  
299 0 my $lpnum = 1;
300 0 ▶ for (; $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $tokens->[$i]) 0 0 0
301 0 $token_type = $token->{type};
302  
303 0 ▶ if ($token_type == LEFT_PAREN) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token_type == 107) { } 0 0 0
elsif ($token_type == 108) { } 0 0 0
elsif ($token_type == 137 and $token->{'data'} eq '$_') { } 0 0 0
304 0 $lpnum++;
305 }
306 elsif ($token_type == RIGHT_PAREN) {
307 0 ▶ last if --$lpnum <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if --$lpnum <= 0 0 0 0
308 }
309 ▶ elsif ($token_type == SPECIFIC_VALUE && $token->{data} eq '$_') {
Condition0%0/3
$token_type == 137 and $token->{"data"} eq "\$_"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 137 and $token->{"data"} eq "\$_"
$token_type == 137 $token->{"data"} eq "\$_"
Truth table0%0/3
A and B
A= $token_type == 137B= $token->{"data"} eq "\$_"
ABresult
0X0
100
111
310 push @violations, {
311 filename => $file,
312 line => $token->{line},
313 0 description => DESC,
314 explanation => EXPL,
315 policy => __PACKAGE__,
316 };
317 0 last;
318 }
319 }
320 }
321 }
322 elsif ($token_data eq 'undef') {
323 0 ▶ $token = $tokens->[++$i] or last;
Branch: 1 branch
BranchTrueFalseTotal
$token = $$tokens[++$i] or last 0 0 0
324 0 $token_type = $token->{type};
325 0 $token_data = $token->{data};
326 0 ▶ if ($token_type == SPECIFIC_VALUE && $token_data eq '$_') {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 137 and $token_data eq '$_') { } 0 0 0
elsif ($token_type == 107) { } 0 0 0
Condition0%0/3
$token_type == 137 and $token_data eq "\$_"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 137 and $token_data eq "\$_"
$token_type == 137 $token_data eq "\$_"
Truth table0%0/3
A and B
A= $token_type == 137B= $token_data eq "\$_"
ABresult
0X0
100
111
327 push @violations, {
328 filename => $file,
329 line => $token->{line},
330 0 description => DESC,
331 explanation => EXPL,
332 policy => __PACKAGE__,
333 };
334 0 last;
335 }
336 elsif ($token_type == LEFT_PAREN) {
337 0 my $lpnum = 1;
338 0 ▶ for (; $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $tokens->[$i]) 0 0 0
339 0 $token_type = $token->{type};
340  
341 0 ▶ if ($token_type == LEFT_PAREN) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token_type == 107) { } 0 0 0
elsif ($token_type == 108) { } 0 0 0
elsif ($token_type == 137 and $token->{'data'} eq '$_') { } 0 0 0
342 0 $lpnum++;
343 }
344 elsif ($token_type == RIGHT_PAREN) {
345 0 ▶ last if --$lpnum <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if --$lpnum <= 0 0 0 0
346 }
347 ▶ elsif ($token_type == SPECIFIC_VALUE && $token->{data} eq '$_') {
Condition0%0/3
$token_type == 137 and $token->{"data"} eq "\$_"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 137 and $token->{"data"} eq "\$_"
$token_type == 137 $token->{"data"} eq "\$_"
Truth table0%0/3
A and B
A= $token_type == 137B= $token->{"data"} eq "\$_"
ABresult
0X0
100
111
348 push @violations, {
349 filename => $file,
350 line => $token->{line},
351 0 description => DESC,
352 explanation => EXPL,
353 policy => __PACKAGE__,
354 };
355 0 last;
356 }
357 }
358 }
359 }
360 elsif ($token_data eq 'substr') {
361 0 ▶ $token = $tokens->[++$i] or last;
Branch: 1 branch
BranchTrueFalseTotal
$token = $$tokens[++$i] or last 0 0 0
362  
363 0 ▶ if ($token_type == LEFT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 107) 0 0 0
364 0 ▶ $token = $tokens->[++$i] or last;
Branch: 1 branch
BranchTrueFalseTotal
$token = $$tokens[++$i] or last 0 0 0
365 }
366  
367 0 ▶ if ($token->{type} == SPECIFIC_VALUE && $token->{data} eq '$_') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 137 and $token->{"data"} eq "\$_") 0 0 0
Condition0%0/3
$token->{"type"} == 137 and $token->{"data"} eq "\$_"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->{"type"} == 137 and $token->{"data"} eq "\$_"
$token->{"type"} == 137 $token->{"data"} eq "\$_"
Truth table0%0/3
A and B
A= $token->{"type"} == 137B= $token->{"data"} eq "\$_"
ABresult
0X0
100
111
368 push @violations, {
369 filename => $file,
370 line => $token->{line},
371 0 description => DESC,
372 explanation => EXPL,
373 policy => __PACKAGE__,
374 };
375 0 last;
376 }
377 }
378 }
379 }
380 }
381 }
382 }
383  
384 0 return \@violations;
385 }
386  
387 2 1;
388  
« Perl/Lint/Policy/RegularExpressions/ProhibitUnusedCapture.pm ↑ Summary Perl/Lint/Policy/Variables/ProhibitPackageVars.pm »