Branch Coverage

blib/lib/App/perlimports/Document.pm
Criterion Covered Total %
branch 115 152 75.6


line true false branch
325 1 1762 if $_[1]->isa("PPI::Statement::Package")
327 31 1 if (not $pkgs or $pkgs->[0]->namespace eq "main")
339 0 1 unless $notional_file eq $provided_file
398 13 408 if $self->is_sub_name("$word")
400 4 404 if not $word->isa("PPI::Token::Symbol") and is_method_call($word)
402 5 399 if $self->_is_word_interpreted_as_string($word)
451 62 2 unless exists $imports{$pkg}
459 29 35 if ($found_for_include)
460 2 27 if ($imports{$pkg}) { }
481 31 1 unless @{$sub_ex;}
487 1 2 if ($arg->isa("PPI::Structure::Constructor"))
490 1 0 if (XXX)
491 1 0 if (XXX)
508 14 388 if ($child->isa("PPI::Structure::List") and not defined $imports)
512 351 8 unless ($child->isa("PPI::Token::QuoteLike::Words") or $child->isa("PPI::Token::Quote::Single"))
516 4 47 if (defined $imports) { }
528 0 15 unless defined $snippet
535 1 14 unless defined $doc
538 8 6 unless $doc->find("PPI::Token::Symbol")
546 2 3 if $cast eq "\\"
552 2 1 unless $cast_as_doc->find("PPI::Token::Symbol")
557 1 2 if ($words and scalar @$words == 1 and $full_cast =~ /([\$\@\%])\{$words->[0]}/)
566 2 1 if is_function_call($word)
578 3 9 if (not $token->isa("PPI::Token::Quote") or $token->isa("PPI::Token::Quote::Single"))
586 1 8 unless $doc
589 5 3 unless $quotes
607 1791 0 unless $_[1]->isa("PPI::Token::Quote") and not $_[1]->isa("PPI::Token::Quote::Single") or $_[1]->isa("PPI::Token::Quote::Interpolate") or $_[1]->isa("PPI::Token::QuoteLike::Regexp")
614 25 8 unless $self->ppi_document->find(sub {
617 1 8 if ($token->isa("PPI::Token::Regexp") or $token->isa("PPI::Token::QuoteLike::Regexp"))
638 31 2 unless $self->ppi_document->find(sub {
642 1 2 if $heredoc =~ /'/
652 31 2 unless $self->ppi_document->find(sub {
655 0 2 unless ($cast->snext_sibling and $cast->snext_sibling->isa("PPI::Structure::Block"))
662 2 0 if ($sibling =~ /{(\w+)}/)
690 0 36 if ($self->_has_never_export_modules)
708 26 8 unless $self->ppi_document->find(sub {
712 11 0 if ($children[0] eq "sub" and $children[1]->isa("PPI::Token::Word"))
737 1 53 if (exists $self->original_imports->{$module_name} and &any(sub {
739 28 26 unless $self->original_imports->{$module_name}
758 2429 1 unless $_[1]->isa("PPI::Token::Word") and $_[1]->content =~ /\A$module_name::[a-zA-Z0-9_]*\z/ || $_[1]->content eq $module_name && $_[1]->snext_sibling eq '->'
768 9 4 if $self->ppi_document->find(sub {
774 1 0 if $key =~ /\A[*\$\@\%]+$module_name::[a-zA-Z0-9_]+\z/
777 0 0 if $key =~ /\A$module_name::[a-zA-Z0-9_]+\z/
805 0 196 if $module eq "Exporter"
807 130 66 if ($self->_has_inspector_for($module))
811 0 66 if ($self->_cache)
816 0 0 if (-e $file)
824 0 0 if ($inspector)
870 1 41 if (not $self->_preserve_duplicates and exists $processed{$include->module})
873 0 1 if ($self->lint)
912 0 41 unless $elem
916 15 26 unless ($self->_preserve_unused)
919 2 12 if ($args[0] and $args[0] eq "()" and not $self->_is_used_fully_qualified($include->module))
923 0 2 if ($self->lint)
944 1 38 if (my $err = App::perlimports::Sandbox::eval_pkg($elem->module, "$elem"))
957 0 38 if (not $inserted) { }
963 2 36 if ($self->lint)
968 2 0 if ($before ne $after)
986 0 36 if (not $doc) { }
1006 1 41 $self->lint ? :
1020 0 2 if ($self->json) { }
1026 0 0 if ($lines[0] =~ /[^\s]/)
1049 0 2 if $after_deleted
1059 0 2 if ($self->json) { }
1073 0 2 unless ($next->isa("PPI::Token::Whitespace") or $next->isa("PPI::Token::Comment"))
1078 3 4 if $next eq "\n"
1087 0 0 defined $ENV{'HOME'} && -d path($ENV{'HOME'}, '.cache') ? :
1105 42 0 unless $self->_cache
1109 0 0 unless @names
1118 0 0 if -e $file
1133 45 359 unless $word->statement and $word->isa("PPI::Token::Word")
1137 1 358 if is_hash_key($word) and @children == 1
1146 37 321 unless $word->content =~ /^[a-zA-Z_][a-zA-Z0-9_]*$/
1149 321 175 if &refaddr($current) == &refaddr($word)
1151 5 316 unless my $current = shift @children
1152 4 312 if $current->isa("PPI::Token::Operator") and $current->content eq "=>"