Branch Coverage

blib/lib/Perl/Critic/Policy/Variables/ProhibitUnusedVarsStricter.pm
Criterion Covered Total %
branch 214 294 72.7


line true false branch
193 58 0 if (my $token = $document->last_token)
204 0 58 if $self->{'_dump'}
222 0 0 if (defined $fn) { }
249 2 56 if $self->{'_check_catch'}
277 0 9 ($code = $doc->can('ppix_regexp_from_element')) ? :
294 0 72 unless my $ppi = $ppix_elem->ppi
308 199 41 if (my $parent = $elem->parent) { }
321 0 85 unless my $outer_top = $outer_elem->top
324 0 120 unless my $inner_top = $inner_elem->top
326 81 39 if $inner_top == $outer_top
328 4 35 unless $inner_elem = $self->_get_parent_element($inner_top)
339 40 54 unless $document->find("PPI::Statement::Variable")
342 544 20 unless $document->find($class)
343 0 30 unless my $str = $self->_get_ppix_quotelike($elem)
345 7 23 unless $str->find("PPIx::QuoteLike::Token::Interpolation")
347 0 27 unless my $ppi = $self->_get_derived_ppi_document($code, $elem)
355 275 7 unless $document->find($class)
356 0 9 unless my $pre = $self->_get_ppix_regexp($elem)
358 0 9 unless $pre->find("PPIx::Regexp::Token::Code")
360 0 9 unless my $ppi = $self->_get_derived_ppi_document($code, $elem)
378 0 2 unless $document->find("PPI::Token::Word")
379 5 2 unless $CATCH eq $word->content
381 0 2 unless my $list = $word->snext_sibling
383 0 2 unless $list->isa("PPI::Structure::List")
385 0 2 unless my $block = $list->snext_sibling
387 0 2 unless $block->isa("PPI::Structure::Block")
389 0 2 unless $list->find("PPI::Token::Symbol")
407 0 98 unless my $elem = $declaration->schild(0)
424 161 116 unless $elem->isa("PPI::Token::Word")
427 16 100 unless defined(my $is_global = $GLOBAL_DECLARATION{$elem->content})
430 2 98 unless $elem = $elem->snext_sibling
439 89 9 if ($elem->isa('PPI::Token::Symbol')) { }
9 0 elsif ($elem->isa('PPI::Structure::List')) { }
443 0 9 unless $elem->find("PPI::Token::Symbol")
452 18 85 unless $elem->isa("PPI::Token::Operator")
455 3 82 if $IS_COMMA{$content}
457 80 2 if ($Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter::EQUAL eq $content)
472 84 21 if ($assign)
473 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
494 96 179 unless $elem and $elem = $elem->snext_sibling
533 101 15 unless $document->find($class)
536 0 21 unless my $type = $declaration->schild(0)
541 9 12 if ($info->{'want'}{$type_str})
543 0 9 unless my $sib = $type->snext_sibling
547 3 6 unless $sib->isa("PPI::Token::Word")
550 0 6 unless defined(my $is_global = $GLOBAL_DECLARATION{$sib_content})
553 0 6 unless my $symbol = $sib->snext_sibling
555 0 6 unless $symbol->isa("PPI::Token::Symbol")
580 0 80 unless my $next_sib = $elem->snext_sibling
582 12 68 if ($next_sib->isa('PPI::Token::Word')) { }
8 60 elsif ($next_sib->isa('PPI::Token::Symbol')) { }
586 1 11 if $self->{'_allow_if_computed_by'}{$content}
592 0 8 unless $next_sib = $next_sib->snext_sibling
594 8 0 unless $next_sib->isa("PPI::Token::Operator") and "->" eq $next_sib->content
597 0 0 unless $next_sib = $next_sib->snext_sibling
600 0 0 if $self->{'_allow_if_computed_by'}{$content}
626 75 5 unless "state" eq $declaration->type
634 2 10 if $next_sib->isa("PPI::Token::Operator") and $LOW_PRECEDENCE_BOOLEAN{$next_sib->content}
645 8 3 unless my $sib = $elem->$method
647 1 2 if $sib->isa("PPI::Token::Operator")
663 0 98 unless my $parent = $self->_get_parent_element($elem)
667 10 88 if ($parent->isa('PPI::Structure::List')) { }
23 65 elsif ($parent->isa('PPI::Structure::Block')) { }
669 1 9 unless $cast = $parent->sprevious_sibling
674 9 14 unless my $prev = $parent->sprevious_sibling
677 1 13 unless $prev->isa("PPI::Token::Word")
679 9 4 unless "do" eq $prev->content
687 67 11 unless $cast
688 5 6 unless $cast->isa("PPI::Token::Cast")
697 0 98 unless my $parent = $self->_get_parent_element($elem)
699 64 34 unless my $stmt = $parent->statement
701 32 2 unless $stmt->isa("PPI::Statement::Break")
703 0 2 unless my $kind = $stmt->schild(0)
723 2 95 unless $document->find("PPI::Token::Symbol")
725 113 94 if $self->{$PACKAGE}{'is_declaration'}{&refaddr($symbol)}
737 96 1 unless $document->find("PPI::Token::ArrayIndex")
741 0 1 unless $name =~ s/ \A \$ [#] /\@/msx
761 152 42 unless $document->find($class)
763 8 54 unless $LEFT_BRACE eq $elem->start
765 10 44 unless my $previous = $elem->sprevious_sibling
767 40 4 unless $previous->isa("PPI::Token::Cast") or $previous->isa("PPI::Token::Magic")
771 0 4 unless my $sigil = $CAST_FOR_BARE_BRACKETED_VARIABLE{$previous->content}
775 0 4 unless 1 == @kids
777 0 4 unless $kids[0]->isa("PPI::Statement")
781 0 4 unless 1 == @grand_kids
786 3 1 unless $grand_kids[0]->isa("PPI::Token::Word") or $grand_kids[0]->isa("PPI::Token::Number::Version")
835 56 652 unless exists $arg{$key}
838 0 118 if ($self->{'_trace'}{$sym_name})
859 94 2 unless defined $symbol_name
862 26 70 unless ($declaration = $self->{$PACKAGE}{'declared'}{$symbol_name})
866 10 16 unless my $prev = $symbol->sprevious_sibling
868 8 8 unless $prev->isa("PPI::Token::Word")
871 3 5 unless exists $GLOBAL_DECLARATION{$content}
878 0 5 unless ($cast)
880 0 0 if $parent = $self->_get_parent_element($prev)
893 33 37 if (delete $self->{$PACKAGE}{'need_sort'})
904 0 14 unless $Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter::b->[1][3] <=> $Perl::Critic::Policy::Variables::ProhibitUnusedVarsStricter::a->[1][3]
917 15 70 unless $self->_derived_element_is_in_lexical_scope_after_statement_containing($symbol, $decl_scope->{'declaration'})
919 0 70 if ($self->{'_trace'}{$symbol_name})
934 0 0 if ($self->{'_trace'}{$symbol_name})
950 4 81 unless my $effective_inner = $self->_get_lowest_in_same_doc($inner_elem, $outer_elem)
974 562 20 unless $document->find($class)
977 0 30 unless my $str = $self->_get_ppix_quotelike($double_quotish)
981 7 23 unless $str->find("PPIx::QuoteLike::Token::Interpolation")
983 0 27 unless my $subdoc = $self->_get_derived_ppi_document($interp, $double_quotish)
1004 284 7 unless $document->find($class)
1006 0 9 unless my $pre = $self->_get_ppix_regexp($regex)
1010 0 9 unless $pre->find("PPIx::Regexp::Token::Code")
1033 94 3 unless $document->find($class)
1040 0 3 unless $sig =~ / [[:alpha:]\d] /msx
1055 2 3 if / \A [\$\@%] (?: \s* = | \z ) /msx
1069 0 3 unless my $subdoc = $self->_element_to_ppi($elem, join($", @args))
1089 1 117 if $declaration->{'is_global'}
1091 62 55 if $declaration->{'used'}
1093 1 54 if $declaration->{'is_allowed_computation'}
1096 2 1 if $declaration->{'is_state_in_expression'} and $self->{'_allow_state_in_expression'}
1099 4 48 if $declaration->{'taking_reference'} and not $self->{'_prohibit_reference_only_variables'}
1102 2 46 if $declaration->{'returned_lexical'} and not $self->{'_prohibit_returned_lexicals'}
1105 6 4 if $declaration->{'is_unpacking'} and $self->{'_allow_unused_subroutine_arguments'}
1114 0 18 unless $a->logical_line_number <=> $b->logical_line_number
1141 0 81 unless $inner_elem->top == $outer_elem->top
1148 6 75 if ($outer_elem->scope)
1159 0 75 unless my $stmt = $outer_elem->statement
1164 0 77 unless $last_elem = $last_elem->last_element
1168 0 75 unless my $stmt_loc = $last_elem->location
1171 0 75 unless my $inner_loc = $inner_elem->location
1174 0 75 if $stmt_loc->[0] > $inner_loc->[0]
1176 5 70 if $stmt_loc->[0] == $inner_loc->[0] and $stmt_loc->[1] >= $inner_loc->[1]
1192 0 75 if _inner_is_defined_by_outer($inner_elem, $parent) and _location_is_in_right_hand_side_of_assignment($parent, $inner_elem)
1196 0 75 unless $parent = $parent->parent
1213 39 36 unless $outer_elem->isa("PPI::Statement::Variable") and $inner_elem->isa("PPI::Token::Symbol")
1230 0 6 unless $outer_elem->scope
1232 0 6 unless $inner_elem->descendant_of($outer_elem)
1234 6 0 if ($outer_elem->isa("PPI::Statement::Compound"))
1235 0 6 unless my $first = $outer_elem->schild(0)
1237 6 0 if ({"for", 1, "foreach", 1}->{$first->content})
1240 12 6 unless $next->isa("PPI::Structure::List")
1260 84 27 unless $kid->isa("PPI::Token::Operator") and "=" eq $kid->content
1264 0 27 if $l->[0] > $inner_loc->[0]
1266 0 27 if $l->[0] == $inner_loc->[0] and $l->[1] >= $inner_loc->[1]
1288 0 3 if exists $self->{$PACKAGE}{'sub_document'}{&refaddr($elem)}
1290 0 3 unless defined $content
1296 3 0 if ($location)
1298 0 3 if (defined($fn = $location->[4])) { }
1311 3 0 if ($location)
1320 3 0 if $annotation = $doc->child(0) and $annotation->isa("PPI::Token::Comment") and $annotation->content =~ / \A \#line\b /msx
1328 3 0 if $wid and $annotation = $doc->child(0) and $annotation->isa("PPI::Token::Whitespace") and $wid == length $annotation->content