Branch Coverage

blib/lib/Perl/Lint/Policy/ValuesAndExpressions/ProhibitMagicNumbers.pm
Criterion Covered Total %
branch 124 152 81.5


line true false branch
48 56 70 if (my $this_policies_arg = $args->{'prohibit_magic_numbers'})
53 29 27 if (defined $allowed_values)
58 8 28 if (defined $begin and defined $end) { }
75 19 37 if (defined $allowed_types)
84 1 55 if (defined $constant_creator_subroutines)
98 21 7 if ($token_type == 93 or $token_type == 71 or $token_type == 122 and $constant_creator_subroutines{$token_data})
105 56 211 if ($token_type == 106)
112 8 770 if ($token_type == 127 and $token_data eq 'Readonly')
113 0 8 unless $token = $$tokens[++$i]
115 8 0 if ($token->{'type'} == 126)
116 0 8 unless $token = $$tokens[++$i]
119 8 0 if ($token->{'type'} == 127)
120 2 6 if ($token_data eq 'Scalar' or $token_data eq 'Array') { }
1 5 elsif ($token_data eq 'Array1') { }
125 2 12 if ($token_type == 106)
148 151 0 if ($token_data eq '$VERSION' and $token_type == 166 || $token_type == 194)
154 151 1367 if $token->{'type'} == 106
159 94 9 if ($token_type == 65 or $token_type == 124 and !$allow_to_the_right_of_a_fat_comma || $is_readonly_array1_ctx)
167 4 527 if ($token_type == 203)
177 0 19 if ($token_type == 109) { }
4 15 elsif ($token_type == 110) { }
5 10 elsif ($token_type == 106) { }
181 4 0 if --$lbnum <= 0
192 2 2 if (scalar @statements > 1)
195 0 2 unless my $return_value_token = pop @$last_statement
196 0 2 if ($return_value_token->{'type'} == 0)
197 0 0 unless $return_value_token = pop @$last_statement
201 2 0 if ($return_value_token->{'type'} == 170) { }
0 0 elsif ($return_value_token->{'type'} == 171) { }
208 2 0 if ($invalid_token)
222 3 524 if ($token_type == 133 or $token_type == 134)
226 3 19 if ($token_type == 106 or $token_type == 109) { }
2 17 elsif ($token_type == 59) { }
230 0 2 unless my $begin = $$tokens[$i - 1]
231 0 2 unless my $end = $$tokens[$i + 1]
232 1 1 if ($begin->{'type'} == 170 and $end->{'type'} == 170)
233 1 0 unless ($allowed_values{$begin->{'data'}} and $allowed_values{$end->{'data'}})
249 4 520 if ($token_type == 111)
250 0 4 unless my $next_token = $$tokens[$i + 1]
251 4 0 if ($next_token->{'type'} == 170)
253 0 4 unless $next_token = $$tokens[$i + 2]
256 3 1 if ($next_token->{'type'} == 112) { }
1 0 elsif ($next_token->{'type'} != 104) { }
258 1 2 if (not $allowed_values{$num} and $num ne -1)
266 2 2 if ($invalid_token)
287 0 273 unless my $token = $$tokens[$$i]
291 89 184 if ($token_type == 65) { }
13 171 elsif ($token_type == 124) { }
294 0 89 unless $token = $$tokens[++$$i]
300 10 3 if (not $allow_to_the_right_of_a_fat_comma or $is_readonly_array1_ctx)
304 0 13 unless $token = $$tokens[++$$i]
312 39 234 if ($token_type == 171) { }
122 112 elsif ($token_type == 170) { }
9 103 elsif ($token_type == 107) { }
12 91 elsif ($token_type == 111) { }
322 1 59 if ($token_type == 107) { }
10 49 elsif ($token_type == 108) { }
326 9 1 if --$lpnum <= 0
338 2 144 if ($token_type == 111) { }
14 130 elsif ($token_type == 112) { }
342 12 2 if --$lbnum <= 0
350 42 231 if ($is_in_assigning_context and $invalid_token)
368 20 104 if (my($base_type) = $token_data =~ /\A[0-9]([b0xe]).+\z/)
369 5 15 if ($1 eq 'b') { }
6 9 elsif ($1 eq '0') { }
5 4 elsif ($1 eq 'x') { }
4 0 elsif ($1 eq 'e') { }
370 2 3 unless $allowed_types{'Binary'}
373 4 2 unless $allowed_types{'Octal'}
376 2 3 unless $allowed_types{'Hex'}
379 2 2 unless $allowed_types{'Exp'}
383 0 114 unless ($allowed_types{'Int'})
387 27 77 unless ($allowed_values{'all_integers'} or $allowed_values{$token_data + 0})
399 30 9 if ($i and $allowed_types{'Float'} and $allowed_values{$token_data + 0}) { }
8 1 elsif (not $allowed_values{'all_integers'} && $token_data =~ /[.]0+\z/) { }
401 0 30 if ($next_token and $next_token->{'type'} == 171)