Branch Coverage

blib/lib/Perl/Critic/Policy/Variables/ProhibitUnusedVarsStricter.pm
Criterion Covered Total %
branch 219 300 73.0


line true false branch
195 60 0 if (my $token = $document->last_token)
206 0 60 if $self->{'_dump'}
224 0 0 if (defined $fn) { }
252 2 58 if $self->{'_check_catch'}
280 0 9 ($code = $doc->can('ppix_regexp_from_element')) ? :
297 0 72 unless my $ppi = $ppix_elem->ppi
311 209 43 if (my $parent = $elem->parent) { }
324 0 85 unless my $outer_top = $outer_elem->top
327 0 120 unless my $inner_top = $inner_elem->top
329 81 39 if $inner_top == $outer_top
331 4 35 unless $inner_elem = $self->_get_parent_element($inner_top)
342 42 54 unless $document->find("PPI::Statement::Variable")
345 556 20 unless $document->find($class)
346 0 30 unless my $str = $self->_get_ppix_quotelike($elem)
348 7 23 unless $str->find("PPIx::QuoteLike::Token::Interpolation")
350 0 27 unless my $ppi = $self->_get_derived_ppi_document($code, $elem)
358 281 7 unless $document->find($class)
359 0 9 unless my $pre = $self->_get_ppix_regexp($elem)
361 0 9 unless $pre->find("PPIx::Regexp::Token::Code")
363 0 9 unless my $ppi = $self->_get_derived_ppi_document($code, $elem)
381 0 2 unless $document->find("PPI::Token::Word")
382 5 2 unless $CATCH eq $word->content
384 0 2 unless my $list = $word->snext_sibling
386 0 2 unless $list->isa("PPI::Structure::List")
388 0 2 unless my $block = $list->snext_sibling
390 0 2 unless $block->isa("PPI::Structure::Block")
392 0 2 unless $list->find("PPI::Token::Symbol")
410 0 100 unless my $elem = $declaration->schild(0)
427 266 120 unless $elem->isa("PPI::Token::Word")
430 18 102 unless defined(my $is_global = $GLOBAL_DECLARATION{$elem->content})
433 2 100 unless $elem = $elem->snext_sibling
442 91 9 if ($elem->isa('PPI::Token::Symbol')) { }
9 0 elsif ($elem->isa('PPI::Structure::List')) { }
446 0 9 unless $elem->find("PPI::Token::Symbol")
457 86 21 if ($assign)
458 0 86 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
479 98 286 unless $elem and $elem = $elem->snext_sibling
505 18 96 unless $elem->isa("PPI::Token::Operator")
508 6 90 if $IS_COMMA{$content}
510 84 6 if ($Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter::EQUAL eq $content) { }
4 2 elsif ($IS_INC_DEC{$content}) { }
558 105 15 unless $document->find($class)
561 0 25 unless my $type = $declaration->schild(0)
566 13 12 if ($info->{'want'}{$type_str})
568 0 13 unless my $sib = $type->snext_sibling
572 5 8 unless $sib->isa("PPI::Token::Word")
575 0 8 unless defined(my $is_global = $GLOBAL_DECLARATION{$sib_content})
578 0 8 unless my $symbol = $sib->snext_sibling
580 0 8 unless $symbol->isa("PPI::Token::Symbol")
605 0 84 unless my $next_sib = $elem->snext_sibling
607 12 72 if ($next_sib->isa('PPI::Token::Word')) { }
8 64 elsif ($next_sib->isa('PPI::Token::Symbol')) { }
611 1 11 if $self->{'_allow_if_computed_by'}{$content}
617 0 8 unless $next_sib = $next_sib->snext_sibling
619 8 0 unless $next_sib->isa("PPI::Token::Operator") and "->" eq $next_sib->content
622 0 0 unless $next_sib = $next_sib->snext_sibling
625 0 0 if $self->{'_allow_if_computed_by'}{$content}
650 82 2 unless (defined $type)
651 0 82 unless $declaration->can("type")
658 77 7 unless "state" eq $type
666 2 12 if $next_sib->isa("PPI::Token::Operator") and $LOW_PRECEDENCE_BOOLEAN{$next_sib->content}
677 18 9 unless my $sib = $elem->$method
679 1 8 if $sib->isa("PPI::Token::Operator")
695 0 100 unless my $parent = $self->_get_parent_element($elem)
699 12 88 if ($parent->isa('PPI::Structure::List')) { }
23 65 elsif ($parent->isa('PPI::Structure::Block')) { }
701 1 11 unless $cast = $parent->sprevious_sibling
706 9 14 unless my $prev = $parent->sprevious_sibling
709 1 13 unless $prev->isa("PPI::Token::Word")
711 9 4 unless "do" eq $prev->content
719 67 13 unless $cast
720 7 6 unless $cast->isa("PPI::Token::Cast")
729 0 100 unless my $parent = $self->_get_parent_element($elem)
731 64 36 unless my $stmt = $parent->statement
733 32 4 unless $stmt->isa("PPI::Statement::Break")
735 0 4 unless my $kind = $stmt->schild(0)
755 2 97 unless $document->find("PPI::Token::Symbol")
757 117 98 if $self->{$PACKAGE}{'is_declaration'}{&refaddr($symbol)}
769 98 1 unless $document->find("PPI::Token::ArrayIndex")
773 0 1 unless $name =~ s/ \A \$ [#] /\@/msx
793 156 42 unless $document->find($class)
795 8 54 unless $LEFT_BRACE eq $elem->start
797 10 44 unless my $previous = $elem->sprevious_sibling
799 40 4 unless $previous->isa("PPI::Token::Cast") or $previous->isa("PPI::Token::Magic")
803 0 4 unless my $sigil = $CAST_FOR_BARE_BRACKETED_VARIABLE{$previous->content}
807 0 4 unless 1 == @kids
809 0 4 unless $kids[0]->isa("PPI::Statement")
813 0 4 unless 1 == @grand_kids
818 3 1 unless $grand_kids[0]->isa("PPI::Token::Word") or $grand_kids[0]->isa("PPI::Token::Number::Version")
867 62 694 unless exists $arg{$key}
870 0 126 if ($self->{'_trace'}{$sym_name})
891 98 2 unless defined $symbol_name
894 30 70 unless ($declaration = $self->{$PACKAGE}{'declared'}{$symbol_name})
898 10 20 unless my $prev = $symbol->sprevious_sibling
900 8 12 unless $prev->isa("PPI::Token::Word")
903 3 9 unless exists $GLOBAL_DECLARATION{$type}
910 0 9 unless ($cast)
912 0 0 if $parent = $self->_get_parent_element($prev)
932 33 37 if (delete $self->{$PACKAGE}{'need_sort'})
943 0 14 unless $Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter::b->[1][3] <=> $Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter::a->[1][3]
956 15 70 unless $self->_derived_element_is_in_lexical_scope_after_statement_containing($symbol, $decl_scope->{'declaration'})
958 0 70 if ($self->{'_trace'}{$symbol_name})
973 0 0 if ($self->{'_trace'}{$symbol_name})
989 4 81 unless my $effective_inner = $self->_get_lowest_in_same_doc($inner_elem, $outer_elem)
1013 574 20 unless $document->find($class)
1016 0 30 unless my $str = $self->_get_ppix_quotelike($double_quotish)
1020 7 23 unless $str->find("PPIx::QuoteLike::Token::Interpolation")
1022 0 27 unless my $subdoc = $self->_get_derived_ppi_document($interp, $double_quotish)
1043 290 7 unless $document->find($class)
1045 0 9 unless my $pre = $self->_get_ppix_regexp($regex)
1049 0 9 unless $pre->find("PPIx::Regexp::Token::Code")
1072 96 3 unless $document->find($class)
1079 0 3 unless $sig =~ / [[:alpha:]\d] /msx
1094 2 3 if / \A [\$\@%] (?: \s* = | \z ) /msx
1108 0 3 unless my $subdoc = $self->_element_to_ppi($elem, join($", @args))
1128 1 125 if $declaration->{'is_global'}
1130 62 63 if $declaration->{'used'}
1132 1 62 if $declaration->{'is_allowed_computation'}
1135 4 3 if $declaration->{'is_state_in_expression'} and $self->{'_allow_state_in_expression'}
1138 4 54 if $declaration->{'taking_reference'} and not $self->{'_prohibit_reference_only_variables'}
1141 4 50 if $declaration->{'returned_lexical'} and not $self->{'_prohibit_returned_lexicals'}
1144 6 4 if $declaration->{'is_unpacking'} and $self->{'_allow_unused_subroutine_arguments'}
1153 0 22 unless $a->logical_line_number <=> $b->logical_line_number
1180 0 81 unless $inner_elem->top == $outer_elem->top
1187 6 75 if ($outer_elem->scope)
1198 0 75 unless my $stmt = $outer_elem->statement
1203 0 77 unless $last_elem = $last_elem->last_element
1207 0 75 unless my $stmt_loc = $last_elem->location
1210 0 75 unless my $inner_loc = $inner_elem->location
1213 0 75 if $stmt_loc->[0] > $inner_loc->[0]
1215 5 70 if $stmt_loc->[0] == $inner_loc->[0] and $stmt_loc->[1] >= $inner_loc->[1]
1231 0 75 if _inner_is_defined_by_outer($inner_elem, $parent) and _location_is_in_right_hand_side_of_assignment($parent, $inner_elem)
1235 0 75 unless $parent = $parent->parent
1252 39 36 unless $outer_elem->isa("PPI::Statement::Variable") and $inner_elem->isa("PPI::Token::Symbol")
1269 0 6 unless $outer_elem->scope
1271 0 6 unless $inner_elem->descendant_of($outer_elem)
1273 6 0 if ($outer_elem->isa("PPI::Statement::Compound"))
1274 0 6 unless my $first = $outer_elem->schild(0)
1276 6 0 if ({"for", 1, "foreach", 1}->{$first->content})
1279 12 6 unless $next->isa("PPI::Structure::List")
1299 84 27 unless $kid->isa("PPI::Token::Operator") and "=" eq $kid->content
1303 0 27 if $l->[0] > $inner_loc->[0]
1305 0 27 if $l->[0] == $inner_loc->[0] and $l->[1] >= $inner_loc->[1]
1327 0 3 if exists $self->{$PACKAGE}{'sub_document'}{&refaddr($elem)}
1329 0 3 unless defined $content
1335 3 0 if ($location)
1337 0 3 if (defined($fn = $location->[4])) { }
1350 3 0 if ($location)
1359 3 0 if $annotation = $doc->child(0) and $annotation->isa("PPI::Token::Comment") and $annotation->content =~ / \A \#line\b /msx
1367 3 0 if $wid and $annotation = $doc->child(0) and $annotation->isa("PPI::Token::Whitespace") and $wid == length $annotation->content