Branch Coverage

blib/lib/Perl/Critic/Policy/Variables/ProhibitUnusedVarsStricter.pm
Criterion Covered Total %
branch 201 272 73.9


line true false branch
190 55 0 if (my $token = $document->last_token)
201 0 55 if $self->{'_dump'}
219 0 0 if (defined $fn) { }
246 2 53 if $self->{'_check_catch'}
274 0 9 ($code = $doc->can('ppix_regexp_from_element')) ? :
291 0 70 unless my $ppi = $ppix_elem->ppi
305 199 38 if (my $parent = $elem->parent) { }
318 0 82 unless my $outer_top = $outer_elem->top
321 0 114 unless my $inner_top = $inner_elem->top
323 78 36 if $inner_top == $outer_top
325 4 32 unless $inner_elem = $self->_get_parent_element($inner_top)
336 36 54 unless $document->find("PPI::Statement::Variable")
339 521 19 unless $document->find($class)
340 0 29 unless my $str = $self->_get_ppix_quotelike($elem)
342 7 22 unless $str->find("PPIx::QuoteLike::Token::Interpolation")
344 0 26 unless my $ppi = $self->_get_derived_ppi_document($code, $elem)
352 263 7 unless $document->find($class)
353 0 9 unless my $pre = $self->_get_ppix_regexp($elem)
355 0 9 unless $pre->find("PPIx::Regexp::Token::Code")
357 0 9 unless my $ppi = $self->_get_derived_ppi_document($code, $elem)
375 0 2 unless $document->find("PPI::Token::Word")
376 5 2 unless $CATCH eq $word->content
378 0 2 unless my $list = $word->snext_sibling
380 0 2 unless $list->isa("PPI::Structure::List")
382 0 2 unless my $block = $list->snext_sibling
384 0 2 unless $block->isa("PPI::Structure::Block")
386 0 2 unless $list->find("PPI::Token::Symbol")
404 0 98 unless my $elem = $declaration->schild(0)
421 161 116 unless $elem->isa("PPI::Token::Word")
424 16 100 unless defined(my $is_global = $GLOBAL_DECLARATION{$elem->content})
427 2 98 unless $elem = $elem->snext_sibling
436 89 9 if ($elem->isa('PPI::Token::Symbol')) { }
9 0 elsif ($elem->isa('PPI::Structure::List')) { }
440 0 9 unless $elem->find("PPI::Token::Symbol")
449 18 85 unless $elem->isa("PPI::Token::Operator")
452 3 82 if $IS_COMMA{$content}
454 80 2 if ($Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter::EQUAL eq $content)
469 84 21 if ($assign)
470 0 84 unless $symbol->logical_line_number < $assign->logical_line_number or $symbol->logical_line_number == $assign->logical_line_number and $symbol->column_number < $assign->column_number
491 96 179 unless $elem and $elem = $elem->snext_sibling
530 95 15 unless $document->find($class)
533 0 21 unless my $type = $declaration->schild(0)
538 9 12 if ($info->{'want'}{$type_str})
540 0 9 unless my $sib = $type->snext_sibling
544 3 6 unless $sib->isa("PPI::Token::Word")
547 0 6 unless defined(my $is_global = $GLOBAL_DECLARATION{$sib_content})
550 0 6 unless my $symbol = $sib->snext_sibling
552 0 6 unless $symbol->isa("PPI::Token::Symbol")
577 0 80 unless my $next_sib = $elem->snext_sibling
579 12 68 if ($next_sib->isa('PPI::Token::Word')) { }
8 60 elsif ($next_sib->isa('PPI::Token::Symbol')) { }
583 1 11 if $self->{'_allow_if_computed_by'}{$content}
589 0 8 unless $next_sib = $next_sib->snext_sibling
591 8 0 unless $next_sib->isa("PPI::Token::Operator") and "->" eq $next_sib->content
594 0 0 unless $next_sib = $next_sib->snext_sibling
597 0 0 if $self->{'_allow_if_computed_by'}{$content}
623 75 5 unless "state" eq $declaration->type
631 2 10 if $next_sib->isa("PPI::Token::Operator") and $LOW_PRECEDENCE_BOOLEAN{$next_sib->content}
642 8 3 unless my $sib = $elem->$method
644 1 2 if $sib->isa("PPI::Token::Operator")
660 0 98 unless my $parent = $self->_get_parent_element($elem)
664 10 88 if ($parent->isa('PPI::Structure::List')) { }
23 65 elsif ($parent->isa('PPI::Structure::Block')) { }
666 1 9 unless $cast = $parent->sprevious_sibling
671 9 14 unless my $prev = $parent->sprevious_sibling
674 1 13 unless $prev->isa("PPI::Token::Word")
676 9 4 unless "do" eq $prev->content
684 67 11 unless $cast
685 5 6 unless $cast->isa("PPI::Token::Cast")
694 0 98 unless my $parent = $self->_get_parent_element($elem)
696 64 34 unless my $stmt = $parent->statement
698 32 2 unless $stmt->isa("PPI::Statement::Break")
700 0 2 unless my $kind = $stmt->schild(0)
720 2 88 unless $document->find("PPI::Token::Symbol")
722 113 84 if $self->{$PACKAGE}{'is_declaration'}{&refaddr($symbol)}
734 89 1 unless $document->find("PPI::Token::ArrayIndex")
738 0 1 unless $name =~ s/ \A \$ [#] /\@/msx
758 141 39 unless $document->find($class)
760 8 51 unless $LEFT_BRACE eq $elem->start
762 10 41 unless my $previous = $elem->sprevious_sibling
764 37 4 unless $previous->isa("PPI::Token::Cast") or $previous->isa("PPI::Token::Magic")
768 0 4 unless my $sigil = $CAST_FOR_BARE_BRACKETED_VARIABLE{$previous->content}
772 0 4 unless 1 == @kids
774 0 4 unless $kids[0]->isa("PPI::Statement")
778 0 4 unless 1 == @grand_kids
783 3 1 unless $grand_kids[0]->isa("PPI::Token::Word") or $grand_kids[0]->isa("PPI::Token::Number::Version")
830 44 646 unless exists $arg{$key}
833 0 115 if ($self->{'_trace'}{$sym_name})
854 84 2 unless defined $symbol_name
857 19 67 unless ($declaration = $self->{$PACKAGE}{'declared'}{$symbol_name})
861 6 13 unless my $prev = $symbol->sprevious_sibling
863 8 5 unless $prev->isa("PPI::Token::Word")
866 3 2 unless exists $GLOBAL_DECLARATION{$content}
873 0 2 unless ($cast)
875 0 0 if $parent = $self->_get_parent_element($prev)
888 30 37 if (delete $self->{$PACKAGE}{'need_sort'})
899 0 14 unless $Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter::b->[1][3] <=> $Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter::a->[1][3]
912 15 67 unless $self->_derived_element_is_in_lexical_scope_after_statement_containing($symbol, $decl_scope->{'declaration'})
914 0 67 if ($self->{'_trace'}{$symbol_name})
929 0 0 if ($self->{'_trace'}{$symbol_name})
945 4 78 unless my $effective_inner = $self->_get_lowest_in_same_doc($inner_elem, $outer_elem)
969 521 19 unless $document->find($class)
972 0 29 unless my $str = $self->_get_ppix_quotelike($double_quotish)
976 7 22 unless $str->find("PPIx::QuoteLike::Token::Interpolation")
978 0 26 unless my $subdoc = $self->_get_derived_ppi_document($interp, $double_quotish)
999 263 7 unless $document->find($class)
1001 0 9 unless my $ppix = $self->_get_ppix_regexp($regex)
1005 0 9 unless $ppix->find("PPIx::Regexp::Token::Code")
1030 1 114 if $declaration->{'is_global'}
1032 59 55 if $declaration->{'used'}
1034 1 54 if $declaration->{'is_allowed_computation'}
1037 2 1 if $declaration->{'is_state_in_expression'} and $self->{'_allow_state_in_expression'}
1040 4 48 if $declaration->{'taking_reference'} and not $self->{'_prohibit_reference_only_variables'}
1043 2 46 if $declaration->{'returned_lexical'} and not $self->{'_prohibit_returned_lexicals'}
1046 6 4 if $declaration->{'is_unpacking'} and $self->{'_allow_unused_subroutine_arguments'}
1055 0 17 unless $a->logical_line_number <=> $b->logical_line_number
1082 0 78 unless $inner_elem->top == $outer_elem->top
1089 6 72 if ($outer_elem->scope)
1100 0 72 unless my $stmt = $outer_elem->statement
1105 0 74 unless $last_elem = $last_elem->last_element
1109 0 72 unless my $stmt_loc = $last_elem->location
1112 0 72 unless my $inner_loc = $inner_elem->location
1115 0 72 if $stmt_loc->[0] > $inner_loc->[0]
1117 5 67 if $stmt_loc->[0] == $inner_loc->[0] and $stmt_loc->[1] >= $inner_loc->[1]
1133 0 72 if _inner_is_defined_by_outer($inner_elem, $parent) and _location_is_in_right_hand_side_of_assignment($parent, $inner_elem)
1137 0 72 unless $parent = $parent->parent
1154 36 36 unless $outer_elem->isa("PPI::Statement::Variable") and $inner_elem->isa("PPI::Token::Symbol")
1171 0 6 unless $outer_elem->scope
1173 0 6 unless $inner_elem->descendant_of($outer_elem)
1175 6 0 if ($outer_elem->isa("PPI::Statement::Compound"))
1176 0 6 unless my $first = $outer_elem->schild(0)
1178 6 0 if ({"for", 1, "foreach", 1}->{$first->content})
1181 12 6 unless $next->isa("PPI::Structure::List")
1201 84 27 unless $kid->isa("PPI::Token::Operator") and "=" eq $kid->content
1205 0 27 if $l->[0] > $inner_loc->[0]
1207 0 27 if $l->[0] == $inner_loc->[0] and $l->[1] >= $inner_loc->[1]