Branch Coverage

blib/lib/Perl/Critic/Policy/RegularExpressions/ProhibitUnusedCapture.pm
Criterion Covered Total %
branch 1 220 0.4


line true false branch
64 1 0 if index($elem->content, "(") == -1
66 0 0 unless my $re = $doc->ppix_regexp_from_element($elem)
67 0 0 if $re->failures
69 0 0 unless my $ncaptures = $re->max_capture_number
79 0 0 unless $re->find("PPIx::Regexp::Structure::NamedCapture")
89 0 0 if _enough_uses_in_regexp($re, \@captures, \%named_captures, $doc)
91 0 0 if ($re->modifier_asserted("g") and not _check_if_in_while_condition_or_block($elem))
97 0 0 unless (%named_captures)
98 0 0 if _enough_assignments($elem, \@captures)
99 0 0 if _is_in_slurpy_array_context($elem)
101 0 0 if _enough_magic($elem, $re, \@captures, \%named_captures, $doc)
113 0 0 unless $re->find("PPIx::Regexp::Token::Reference")
115 0 0 if ($token->is_named) { }
122 0 0 unless $re->find("PPIx::Regexp::Token::Code")
124 0 0 unless my $ppi = $token->ppi
145 0 0 unless $psib
146 0 0 if ($psib->isa("PPI::Token::Operator"))
147 0 0 if "=" eq $psib->content
148 0 0 if "!~" eq $psib->content
154 0 0 unless $psib
156 0 0 if ($psib->isa('PPI::Token::Symbol')) { }
0 0 elsif ($psib->isa('PPI::Structure::Block')) { }
0 0 elsif ($psib->isa('PPI::Structure::List')) { }
161 0 0 if _symbol_is_slurpy($psib)
166 0 0 if _is_preceded_by_array_or_hash_cast($psib)
178 0 0 unless @args
182 0 0 if (1 == @args and $args[0]->isa("PPI::Statement::Expression"))
189 0 0 if (1 == @{$parts[$i];})
191 0 0 if ($var->isa("PPI::Token::Symbol") or $var->isa("PPI::Token::Cast"))
192 0 0 if _has_array_sigil($var)
206 0 0 if _has_array_sigil($symbol)
207 0 0 if _has_hash_sigil($symbol)
208 0 0 if _is_preceded_by_array_or_hash_cast($symbol)
232 0 0 unless $cast
245 0 0 if ($psib and $psib->content eq "=~")
250 0 0 unless ($psib)
252 0 0 unless $parent
253 0 0 if ($parent->isa("PPI::Statement"))
255 0 0 unless $parent
263 0 0 if ($parent->isa("PPI::Structure::List"))
264 0 0 unless my $parent_statement = $parent->statement
265 0 0 unless $parent_statement->isa("PPI::Statement::Compound")
267 0 0 if $parent_statement->type ne "foreach"
270 0 0 if $parent->isa("PPI::Structure::Constructor")
271 0 0 if ($parent->isa("PPI::Structure::Block"))
272 0 0 if builtin::refaddr($elem->statement) eq builtin::refaddr([$parent->schildren]->[-1])
279 0 0 if ($psib->isa("PPI::Token::Operator"))
326 0 0 if (my $prior_token = $elem->sprevious_sibling)
331 0 0 unless _check_rest_of_statement($elem, $arg)
335 0 0 unless _check_rest_of_statement($parent, $arg)
345 0 0 unless $elem
347 0 0 unless my $parent = $elem->parent
348 0 0 unless $parent->isa("PPI::Statement")
350 0 0 unless my $item = $parent = $parent->parent
351 0 0 if ($item->isa("PPI::Structure::Block"))
352 0 0 unless $item = $item->sprevious_sibling
354 0 0 unless $item->isa("PPI::Structure::Condition")
356 0 0 unless $item = $item->sprevious_sibling
357 0 0 unless $item->isa("PPI::Token::Word")
414 0 0 if $parent and not &$parent()
422 0 0 unless $elem
424 0 0 if ($elem->isa("PPI::Token::Regexp"))
425 0 0 _regexp_is_in_split($elem) ? :
428 0 0 if ($elem->isa("PPI::Token::Structure") and ";" eq $elem->content)
435 0 0 unless $elem->isa("PPI::Token::Operator")
439 0 0 unless defined(my $oper_check = $SHORTCUT_OPERATOR{$content})
443 0 0 unless $oper_precedence >= $precedence
460 0 0 unless ($prev = $elem->sprevious_sibling)
462 0 0 unless my $stmt = $elem->statement
464 0 0 unless $stmt->parent
466 0 0 unless $prev = $elem->sprevious_sibling
496 0 0 if ($arg->{'negated'} and _is_condition_of_if_statement($elem))
500 0 0 if $nsib
504 0 0 if &$checker($nsib)
505 0 0 if ($nsib->isa('PPI::Node')) { }
506 0 0 unless _check_node_children($nsib, $arg, $checker)
524 0 0 unless $elem and $elem->isa("PPI::Structure::Condition")
527 0 0 unless my $psib = $elem->sprevious_sibling
529 0 0 unless $psib->isa("PPI::Token::Word")
563 0 0 if &$checker($child)
564 0 0 if ($child->isa('PPI::Node')) { }
565 0 0 unless _check_node_children($child, $arg, $checker)
580 0 0 if (_is_double_quotish_element($elem))
587 0 0 if ($elem->isa("PPI::Token::HereDoc"))
588 0 0 unless $elem->content =~ / \A << ~? \s* ' /msx
597 0 0 $doc->uses_module('English') ? :
603 0 0 unless $elem->isa("PPI::Token::Magic") or $capture_ref->{$content} or $capture_array->{$content} or $capture_hash->{$content}
606 0 0 if ($content =~ / \A \$ ( \d+ ) /msx) { }
0 0 elsif ($capture_array->{$content}) { }
0 0 elsif ($capture_hash->{$content}) { }
0 0 elsif ($capture_ref->{$content}) { }
610 0 0 if (0 < $num)
612 0 0 if ($num <= @{$captures;})
638 0 0 unless my $subscr = $elem->snext_sibling
639 0 0 unless $subscr->isa("PPI::Structure::Subscript")
656 0 0 $doc->uses_module('English') ? :
663 0 0 if $name =~ s/ \A ( [\$\@] ) [{] (?! \^ ) /$1/msx
666 0 0 if ($name =~ / \A \$ ( \d+ ) \z /msx) { }
0 0 elsif ($capture_array->{$name}) { }
0 0 elsif ($capture_ref->{$name} and $content =~ / \G ( [{] [^}]+ [}] | [[] [^]] []] ) /cgmsx) { }
670 0 0 if 0 < $num and $num <= @{$captures;}
695 0 0 unless $elem
699 0 0 if ($elem->isa("PPI::Token::QuoteLike::Command"))
709 0 0 if $elem->isa($class)
721 0 0 if ($suffix =~ / \A [{] ( .*? ) [}] /msx) { }
0 0 elsif ($suffix =~ / \A [[] \s* ( [-+]? \d+ ) \s* []] /msx) { }
731 0 0 if $num >= 0 and $ZERO_BASED_CAPTURE_REFERENCE{$variable_name}
742 0 0 unless defined(my $numbers = $named_captures->{$name})
752 0 0 if $re and $number < 0
754 0 0 if $number <= 0