lib/AutoCode/Root0.pm

filter: Statementstmt 44.2% 42 / 95 Branchbran 45.0% 9 / 20 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 50.0% 8 / 16 Podpod 0.0% 0 / 9 totaltotal 42.5% 63 / 148 CC 13 SCAR 14.2
CC
13
Cov
45%
debug_hints
12.0
stack_trace
6.0
_rearrange
5.0
CRAP 4.1
« lib/AutoCode/AttributeType.pm ↑ Summary lib/AutoCode/Root.pm »
1 package AutoCode::Root0;
2 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 our $VERSION='0.01';
4 7 our $DEBUG;
5 7 our $debug;
6 101 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
7  
8 }
9  
10 74 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
11
12 74 my ($class, @args)=@_;
13 74 my $self={};
14 74 ▶ bless $self, ref($class)||$class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0740
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
15 74 $self->_initialize(@args);
16 74 return $self;
17
18 }
19  
20 55 ▶sub _initialize {
Subroutine _initialize: called CC=1 SCAR=0.0
21 55 my ($self, @args)=@_;
22 55 $self->{DEBUG_HINTS_SLOT} = {};
23 }
24  
25 49 ▶sub _rearrange {
Subroutine _rearrange: called CC=5 SCAR=16.1
26 49 my $dummy = shift;
27 49 my $order = shift;
28  
29 49 ▶ return @_ unless (substr($_[0]||'',0,1) eq '-');
Branch: 1 branch
BranchTrueFalseTotal
unless substr($_[0] || "", 0, 1) eq "-" 3 46 49
Condition100%2/2
$_[0] || ''
l!l
463
MC/DC100%1/1
$_[0] || ''
$_[0]
Truth table100%2/2
A
A= $_[0]
Aresult
11
00
30 46 ▶ push @_,undef unless $#_ %2;
Branch: 1 branch
BranchTrueFalseTotal
unless $#_ % 2 0 46 46
31 46 my %param;
32 46 ▶ while( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 100 46 146
33 100 (my $key = shift) =~ tr/a-z\055/A-Z/d; #deletes all dashes!
34 100 $param{$key} = shift;
35 }
36 46 map { $_ = uc($_) } @$order; # for bug #1343, but is there perf hit here?
37 46 return @param{@$order};
38 }
39  
40 3 ▶sub _load_module {
Subroutine _load_module: called CC=4 SCAR=14.6
41 3 my ($self, $name) = @_;
42 3 my ($module, $load, $m);
43 3 $module = "_<$name.pm";
44 3 ▶ return 1 if $main::{$module};
Branch: 1 branch
BranchTrueFalseTotal
if $main::main::{$module} 0 3 3
45  
46 # untaint operation for safe web-based running (modified after a fix
47 # a fix by Lincoln) HL
48 3 ▶ if ($name !~ /^([\w:]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name =~ /^([\w:]+)$/) 0 3 3
49 0 $self->throw("$name is an illegal perl package name");
50 }
51  
52 3 $load = "$name.pm";
53 # my $io = Bio::Root::IO->new();
54 # catfile comes from IO
55 # $load = $io->catfile((split(/::/,$load)));
56 3 $load=join('/', split(/::/, $load));
57 3 eval {
58 3 require $load;
59 };
60 3 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 3 3
61 0 die "Failed to load module $name. ".$@."\n";
62 # $self->throw("Failed to load module $name. ".$@);
63 }
64 3 return 1;
65 }
66  
67 7 our @DEBUG_HINTS=qw(enable verbosity);
68 7 ▶use constant DEBUG_HINTS_SLOT => '_DEBUG_HINTS';
Subroutine BEGIN: called CC=1 SCAR=0.0
69 0 ▶sub debug_hints {
Subroutine debug_hints: not called CC=3 SCAR=24.8
Pod undocumented
70 0 my $self=shift;
71 0 my %hints = %{$self->{DEBUG_HINTS_SLOT}};
72 0 my ($enable, $verbosity)=$self->_rearrange([qw(ENABLE VERBOSITY)], @_);
73 0 ▶ defined $enable and $hints{enable}=$enable;
Branch: 1 branch
BranchTrueFalseTotal
defined $enable and $hints{"enable"} = $enable 0 0 0
74 0 ▶ defined $verbosity and $hints{verbosity}=$verbosity;
Branch: 1 branch
BranchTrueFalseTotal
defined $verbosity and $hints{"verbosity"} = $verbosity 0 0 0
75 # if(%args){
76 # $hints{$_}=$args{$_} if grep /$_/, @DEBUG_HINTS foreach(keys %args);
77 # }
78 0 return %hints;
79 }
80  
81 142 ▶sub debug {
Subroutine debug: called CC=2 SCAR=9.2
Pod undocumented
82 142 my $self=shift;
83 # return unless($self->{DEBUG_HINTS_SLOT}->{enable});
84
85 142 ▶ return unless $debug;
Branch: 1 branch
BranchTrueFalseTotal
unless $AutoCode::Root0::debug 142 0 142
86 0 my $pkg=caller;
87 0 print STDERR "In $pkg, @_\n";
88 }
89  
90 0 ▶sub throw {
Subroutine throw: not called CC=1 SCAR=6.9
Pod undocumented
91 0 my ($self, $string)=@_;
92 0 my $out ="\n". '-'x20 . ' EXCEPTION '. '-'x20 . "\n";
93 0 $out .= "MSG: $string\n";
94 0 $out .= $self->stack_trace_dump .'-'x51 ."\n";
95 0 die $out;
96 }
97  
98 0 ▶sub warn {
Subroutine warn: not called CC=1 SCAR=6.9
Pod undocumented
99 0 my ($self, $msg)=@_;
100 0 my $out="\n". '-'x20 . ' WARNING '. '-'x20 . "\n";
101 0 $out .= "MSG: $msg\n";
102 0 $out .= '-'x51 ."\n";
103 0 print STDERR $out;
104 }
105  
106 0 ▶sub stack_trace_dump {
Subroutine stack_trace_dump: not called CC=1 SCAR=6.9
Pod undocumented
107 0 my $self=shift;
108 0 my @stack=$self->stack_trace;
109 0 eval{
110 #<< x 3;
111 0 shift @stack;
112 0 shift @stack;shift @stack;
113 };
114 0 my $out;
115 0 my ($module, $function, $file, $position);
116 map {
117 0 ($module, $function, $file, $position)=@$_;
118 0 $out.= "STACK $function $file:$position\n";
119 } @stack;
120 0 return $out;
121 }
122  
123 0 ▶sub stack_trace {
Subroutine stack_trace: not called CC=2 SCAR=17.9
Pod undocumented
124 0 my $self=shift;
125 0 my $i=0;
126 0 my @out=();
127 0 my $prev=[];
128 0 ▶ while(my @call=caller($i++)){
Branch: 1 branch
BranchTrueFalseTotal
if (my(@call) = caller $i++) 0 0 0
129 0 $prev->[3]=$call[3];
130 0 push(@out, $prev);
131 0 $prev=\@call;
132 }
133 0 $prev->[3]='toplevel';
134 0 push @out, $prev;
135 0 return @out;
136 }
137  
138 0 ▶sub _not_implemented_msg {
Subroutine _not_implemented_msg: not called CC=1 SCAR=6.9
139 0 my $self=shift;
140 0 my $pkg=ref $self;
141 0 my $method=(caller(1))[3];
142 0 my $msg="Abstract method [$method] is not implemented by package $pkg.\n";
143 0 return $msg;
144 }
145  
146 0 ▶sub throw_not_implemented {
Subroutine throw_not_implemented: not called CC=1 SCAR=6.9
Pod undocumented
147 0 my $self=shift;
148 0 $self->throw($self->_not_implemented_msg);
149 }
150  
151 0 ▶sub warn_not_implemented {
Subroutine warn_not_implemented: not called CC=1 SCAR=6.9
Pod undocumented
152 0 my $self=shift;
153 0 $self->warn($self->_not_implemented_msg);
154 }
155  
156 7 1;
« lib/AutoCode/AttributeType.pm ↑ Summary lib/AutoCode/Root.pm »