Perl/Analysis/Static/Analysis/Declaration/Package.pm

filter: Statementstmt 88.4% 23 / 26 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 85.7% 30 / 35 CC 3 SCAR 7.3
CC
3
Cov
83%
_convert
3.5
BEGIN
1.0
BEGIN
1.0
CRAP 2.1
« Perl/Analysis/Static/ModuleLister.pm ↑ Summary Perl/Analysis/Static.pm »
1 package Perl::Analysis::Static::Analysis::Declaration::Package;
2 {
3 1 $Perl::Analysis::Static::Analysis::Declaration::Package::VERSION = '0.004'; # TRIAL
4 }
5  
6 # ABSTRACT: find all declarations of packages
7  
8 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use English qw( -no_match_vars ); # Avoids regex performance penalty
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Perl::Analysis::Static::Element::Declaration::Package;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 extends 'Perl::Analysis::Static::Analysis';
15  
16 1 has '_ppi_class' =>
17 ( is => 'rw', isa => 'Str', default => 'PPI::Statement::Package' );
18  
19 2 ▶sub _convert {
Subroutine _convert: called CC=3 SCAR=12.6
20 2 my ( $self, $node ) = @_;
21  
22 # get significant children
23 2 my @schildren = $node->schildren();
24  
25 # the first child is the keyword
26 2 ▶ unless ( $schildren[0] eq 'package' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($schildren[0] eq "package") 0 2 2
27  
28 # CHECK: log a warning if this isn't the case?
29 0 return;
30 }
31  
32 # the sub's name is the second child
33 2 my $name = $schildren[1];
34  
35 2 ▶ unless ( $name->isa('PPI::Token::Word') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name->isa("PPI::Token::Word")) 0 2 2
36 0 die 'PANIC: unexpected class ' . $name->class;
37 0 return;
38 }
39  
40 2 return Perl::Analysis::Static::Element::Declaration::Package->new(
41 name => $name->content,
42 from => $node->location->[0],
43 to => $node->location->[0],
44 ppi_node => $node
45 );
46 }
47  
48  
49 1 1;
50  
51 __END__
« Perl/Analysis/Static/ModuleLister.pm ↑ Summary Perl/Analysis/Static.pm »