Branch Coverage

blib/lib/Perl/Critic/Policy/RegularExpressions/ProhibitUnusedCapture.pm
Criterion Covered Total %
branch 0 216 0.0


line true false branch
59 0 0 if 0 > index($elem->content, "(")
61 0 0 unless my $re = $doc->ppix_regexp_from_element($elem)
62 0 0 if $re->failures
64 0 0 unless my $ncaptures = $re->max_capture_number
74 0 0 unless $re->find("PPIx::Regexp::Structure::NamedCapture")
84 0 0 if _enough_uses_in_regexp($re, \@captures, \%named_captures, $doc)
86 0 0 if ($re->modifier_asserted("g") and not _check_if_in_while_condition_or_block($elem))
92 0 0 if _enough_assignments($elem, \@captures) and not %named_captures
93 0 0 if _is_in_slurpy_array_context($elem) and not %named_captures
94 0 0 if _enough_magic($elem, $re, \@captures, \%named_captures, $doc)
106 0 0 unless $re->find("PPIx::Regexp::Token::Reference")
108 0 0 if ($token->is_named) { }
115 0 0 unless $re->find("PPIx::Regexp::Token::Code")
117 0 0 unless my $ppi = $token->ppi
138 0 0 unless $psib
139 0 0 if ($psib->isa("PPI::Token::Operator"))
140 0 0 if "=" eq $psib->content
141 0 0 if "!~" eq $psib->content
147 0 0 unless $psib
149 0 0 if ($psib->isa('PPI::Token::Symbol')) { }
0 0 elsif ($psib->isa('PPI::Structure::Block')) { }
0 0 elsif ($psib->isa('PPI::Structure::List')) { }
154 0 0 if _symbol_is_slurpy($psib)
159 0 0 if _is_preceded_by_array_or_hash_cast($psib)
171 0 0 unless @args
175 0 0 if (1 == @args and $args[0]->isa("PPI::Statement::Expression"))
182 0 0 if (1 == @{$parts[$i];})
184 0 0 if ($var->isa("PPI::Token::Symbol") or $var->isa("PPI::Token::Cast"))
185 0 0 if _has_array_sigil($var)
199 0 0 if _has_array_sigil($symbol)
200 0 0 if _has_hash_sigil($symbol)
201 0 0 if _is_preceded_by_array_or_hash_cast($symbol)
225 0 0 unless $cast
238 0 0 if ($psib and $psib->content eq "=~")
243 0 0 unless ($psib)
245 0 0 unless $parent
246 0 0 if ($parent->isa("PPI::Statement"))
248 0 0 unless $parent
256 0 0 if ($parent->isa("PPI::Structure::List"))
257 0 0 unless my $parent_statement = $parent->statement
258 0 0 unless $parent_statement->isa("PPI::Statement::Compound")
260 0 0 if $parent_statement->type ne "foreach"
263 0 0 if $parent->isa("PPI::Structure::Constructor")
264 0 0 if ($parent->isa("PPI::Structure::Block"))
265 0 0 if &refaddr(scalar $elem->statement) eq &refaddr([$parent->schildren]->[-1])
272 0 0 if ($psib->isa("PPI::Token::Operator"))
319 0 0 if (my $prior_token = $elem->sprevious_sibling)
324 0 0 unless _check_rest_of_statement($elem, $arg)
328 0 0 unless _check_rest_of_statement($parent, $arg)
338 0 0 unless $elem
340 0 0 unless my $parent = $elem->parent
341 0 0 unless $parent->isa("PPI::Statement")
343 0 0 unless my $item = $parent = $parent->parent
344 0 0 if ($item->isa("PPI::Structure::Block"))
345 0 0 unless $item = $item->sprevious_sibling
347 0 0 unless $item->isa("PPI::Structure::Condition")
349 0 0 unless $item = $item->sprevious_sibling
350 0 0 unless $item->isa("PPI::Token::Word")
407 0 0 if $parent and not &$parent()
415 0 0 unless $elem
417 0 0 if ($elem->isa("PPI::Token::Regexp"))
418 0 0 _regexp_is_in_split($elem) ? :
421 0 0 if ($elem->isa("PPI::Token::Structure") and ";" eq $elem->content)
428 0 0 unless $elem->isa("PPI::Token::Operator")
432 0 0 unless defined(my $oper_check = $SHORTCUT_OPERATOR{$content})
436 0 0 unless $oper_precedence >= $precedence
453 0 0 unless ($prev = $elem->sprevious_sibling)
455 0 0 unless my $stmt = $elem->statement
457 0 0 unless $stmt->parent
459 0 0 unless $prev = $elem->sprevious_sibling
489 0 0 if ($arg->{'negated'} and _is_condition_of_if_statement($elem))
493 0 0 if $nsib
497 0 0 if &$checker($nsib)
498 0 0 if ($nsib->isa('PPI::Node')) { }
499 0 0 unless _check_node_children($nsib, $arg, $checker)
517 0 0 unless $elem and $elem->isa("PPI::Structure::Condition")
520 0 0 unless my $psib = $elem->sprevious_sibling
522 0 0 unless $psib->isa("PPI::Token::Word")
556 0 0 if &$checker($child)
557 0 0 if ($child->isa('PPI::Node')) { }
558 0 0 unless _check_node_children($child, $arg, $checker)
573 0 0 if (_is_double_quotish_element($elem))
580 0 0 if ($elem->isa("PPI::Token::HereDoc"))
581 0 0 unless $elem->content =~ / \A << ~? \s* ' /msx
590 0 0 $doc->uses_module('English') ? :
594 0 0 unless $elem->isa("PPI::Token::Magic") or $capture_ref->{$content}
597 0 0 if ($content =~ / \A \$ ( \d+ ) /msx) { }
0 0 elsif ($capture_array->{$content}) { }
0 0 elsif ($capture_ref->{$content}) { }
601 0 0 if (0 < $num)
603 0 0 if ($num <= @{$captures;})
625 0 0 unless my $subscr = $elem->snext_sibling
626 0 0 unless $subscr->isa("PPI::Structure::Subscript")
643 0 0 $doc->uses_module('English') ? :
650 0 0 if $name =~ s/ \A ( [\$\@] ) [{] (?! \^ ) /$1/msx
653 0 0 if ($name =~ / \A \$ ( \d+ ) \z /msx) { }
0 0 elsif ($capture_array->{$name}) { }
0 0 elsif ($capture_ref->{$name} and $content =~ / \G ( [{] [^}]+ [}] | [[] [^]] []] ) /cgmsx) { }
657 0 0 if 0 < $num and $num <= @{$captures;}
682 0 0 unless $elem
686 0 0 if ($elem->isa("PPI::Token::QuoteLike::Command"))
696 0 0 if $elem->isa($class)
708 0 0 if ($suffix =~ / \A [{] ( .*? ) [}] /msx) { }
0 0 elsif ($suffix =~ / \A [[] \s* ( [-+]? \d+ ) \s* []] /msx) { }
718 0 0 if $num >= 0 and $ZERO_BASED_CAPTURE_REFERENCE{$variable_name}
729 0 0 unless defined(my $numbers = $named_captures->{$name})
739 0 0 if $re and $number < 0
741 0 0 if $number <= 0