lib/OODoc/Text/Subroutine.pm

filter: Statementstmt 16.8% 17 / 101 Branchbran 0.0% 0 / 36 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 27.7% 5 / 18 Podpod 92.3% 12 / 13 totaltotal 20.2% 34 / 168 CC 23 SCAR 35.2
CC
23
Cov
12%
location
90.0
collectedOptions
56.0
init
12.0
CRAP 33.8
« blib/lib/OODoc/Format/Pod.pm ↑ Summary blib/lib/OODoc/Text/Subroutine.pm »
1 # Copyrights 2003-2015 by [Mark Overmeer].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.01.
5  
6 package OODoc::Text::Subroutine;
7 1 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 $VERSION = '2.01';
9  
10 1 ▶use base 'OODoc::Text';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Log::Report 'oodoc';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17  
18 sub init($)
19 0 ▶{ my ($self, $args) = @_;
Subroutine init: not called CC=3 SCAR=24.8
Pod undocumented
20  
21 exists $args->{name}
22 0 ▶ or error __x"no name for subroutine";
Branch: 1 branch
BranchTrueFalseTotal
exists $args->{"name"} or &error(&__x("no name for subroutine")) 0 0 0
23  
24 0 ▶ $self->SUPER::init($args)
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init($args) or return 0 0 0
25 or return;
26  
27 0 $self->{OTS_param} = delete $args->{parameters};
28 0 $self->{OTS_options} = {};
29 0 $self->{OTS_defaults} = {};
30 0 $self->{OTS_diags} = [];
31 0 $self;
32 }
33  
34 #-------------------------------------------
35  
36  
37 sub extends($)
38 0 ▶{ my $self = shift;
Subroutine extends: not called CC=3 SCAR=24.8
Pod documented
39 0 ▶ @_ or return $self->SUPER::extends;
Branch: 1 branch
BranchTrueFalseTotal
@_ or return $self->SUPER::extends 0 0 0
40  
41 0 my $super = shift;
42 0 ▶ if($self->type ne $super->type)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->type ne $super->type) 0 0 0
43 0 { my ($fn1, $ln1) = $self->where;
44 0 my ($fn2, $ln2) = $super->where;
45 0 my ($t1, $t2 ) = ($self->type, $super->type);
46  
47 0 warning __x"subroutine {name}() extended by different type:\n {type1} in {file1} line {line1}\n {type2} in {file2} line {line2}"
48 , name => "$self"
49 , type1 => $t1, file1 => $fn1, line1 => $ln1
50 , type2 => $t2, file2 => $fn2, line2 => $ln2;
51 }
52  
53 0 $self->SUPER::extends($super);
54 }
55  
56 #-------------------------------------------
57  
58  
59 0 ▶sub parameters() {shift->{OTS_param}}
Subroutine parameters: not called CC=1 SCAR=6.9
Pod documented
60  
61 #-------------------------------------------
62  
63  
64 sub location($)
65 0 ▶{ my ($self, $manual) = @_;
Subroutine location: not called CC=9 SCAR=45.0
Pod documented
66 0 my $container = $self->container;
67 0 ▶ my $super = $self->extends
Branch: 1 branch
BranchTrueFalseTotal
my $super = $self->extends or return $container 0 0 0
68 or return $container;
69  
70 0 my $superloc = $super->location;
71 0 my $superpath = $superloc->path;
72 0 my $mypath = $container->path;
73  
74 0 ▶ return $container if $superpath eq $mypath;
Branch: 1 branch
BranchTrueFalseTotal
if $superpath eq $mypath 0 0 0
75
76 0 ▶ if(length $superpath < length $mypath)
Branch: 2 branches
BranchTrueFalseTotal
if (length $superpath < length $mypath) { } 0 0 0
elsif (substr($superpath, 0, length($mypath) + 1) eq "$mypath/") { } 0 0 0
77 0 ▶ { return $container
Branch: 1 branch
BranchTrueFalseTotal
if substr($mypath, 0, length($superpath) + 1) eq "$superpath/" 0 0 0
78 if substr($mypath, 0, length($superpath)+1) eq "$superpath/";
79 }
80 elsif(substr($superpath, 0, length($mypath)+1) eq "$mypath/")
81 0 ▶ { if($superloc->isa("OODoc::Text::Chapter"))
Branch: 2 branches
BranchTrueFalseTotal
if ($superloc->isa('OODoc::Text::Chapter')) { } 0 0 0
elsif ($superloc->isa('OODoc::Text::Section')) { } 0 0 0
82 0 { return $self->manual
83 ->chapter($superloc->name);
84 }
85 elsif($superloc->isa("OODoc::Text::Section"))
86 0 { return $self->manual
87 ->chapter($superloc->chapter->name)
88 ->section($superloc->name);
89 }
90 else
91 0 { return $self->manual
92 ->chapter($superloc->chapter->name)
93 ->section($superloc->section->name)
94 ->subsection($superloc->name);
95 }
96 }
97  
98 0 ▶ unless($manual->inherited($self))
Branch: 1 branch
BranchTrueFalseTotal
unless ($manual->inherited($self)) 0 0 0
99 0 { my ($myfn, $myln) = $self->where;
100 0 my ($superfn, $superln) = $super->where;
101  
102 0 warning __x"subroutine {name}() location conflict:\n {path1} in {file1} line {line1}\n {path2} in {file2} line {line2}"
103 , name => "$self"
104 , path1 => $mypath, file1 => $myfn, line1 => $myln
105 , path2 => $superpath, file2 => $superfn, line2 => $superln;
106 }
107  
108 0 $container;
109 }
110  
111  
112 0 ▶sub path() { shift->container->path }
Subroutine path: not called CC=1 SCAR=6.9
Pod documented
113  
114 #-------------------------------------------
115  
116  
117 sub default($)
118 0 ▶{ my ($self, $it) = @_;
Subroutine default: not called CC=2 SCAR=17.9
Pod documented
119 ref $it
120 0 ▶ or return $self->{OTS_defaults}{$it};
Branch: 1 branch
BranchTrueFalseTotal
ref $it or return $self->{"OTS_defaults"}{$it} 0 0 0
121  
122 0 my $name = $it->name;
123 0 $self->{OTS_defaults}{$name} = $it;
124 0 $it;
125 }
126  
127 #-------------------------------------------
128  
129  
130 0 ▶sub defaults() { values %{shift->{OTS_defaults}} }
Subroutine defaults: not called CC=1 SCAR=6.9
Pod documented
131  
132  
133 sub option($)
134 0 ▶{ my ($self, $it) = @_;
Subroutine option: not called CC=2 SCAR=17.9
Pod documented
135 ref $it
136 0 ▶ or return $self->{OTS_options}{$it};
Branch: 1 branch
BranchTrueFalseTotal
ref $it or return $self->{"OTS_options"}{$it} 0 0 0
137  
138 0 my $name = $it->name;
139 0 $self->{OTS_options}{$name} = $it;
140 0 $it;
141 }
142  
143  
144  
145 sub findOption($)
146 0 ▶{ my ($self, $name) = @_;
Subroutine findOption: not called CC=3 SCAR=24.8
Pod documented
147 0 my $option = $self->option($name);
148 0 ▶ return $option if $option;
Branch: 1 branch
BranchTrueFalseTotal
if $option 0 0 0
149  
150 0 ▶ my $extends = $self->extends or return;
Branch: 1 branch
BranchTrueFalseTotal
my $extends = $self->extends or return 0 0 0
151 0 $extends->findOption($name);
152 }
153  
154  
155 0 ▶sub options() { values %{shift->{OTS_options}} }
Subroutine options: not called CC=1 SCAR=6.9
Pod documented
156  
157  
158 sub diagnostic($)
159 0 ▶{ my ($self, $diag) = @_;
Subroutine diagnostic: not called CC=1 SCAR=6.9
Pod documented
160 0 push @{$self->{OTS_diags}}, $diag;
161 0 $diag;
162 }
163  
164  
165 0 ▶sub diagnostics() { @{shift->{OTS_diags}} }
Subroutine diagnostics: not called CC=1 SCAR=6.9
Pod documented
166  
167  
168 sub collectedOptions(@)
169 0 ▶{ my ($self, %args) = @_;
Subroutine collectedOptions: not called CC=7 SCAR=40.3
Pod documented
170 0 my @extends = $self->extends;
171 0 my %options;
172 0 foreach ($self->extends)
173 0 { my $options = $_->collectedOptions;
174 0 @options{ keys %$options } = values %$options;
175 }
176  
177 0 $options{$_->name}[0] = $_ for $self->options;
178  
179 0 foreach my $default ($self->defaults)
180 0 { my $name = $default->name;
181  
182 0 ▶ unless(exists $options{$name})
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $options{$name}) 0 0 0
183 0 { my ($fn, $ln) = $default->where;
184 0 warning __x"no option {name} for default in {file} line {line}"
185 , name => $name, file => $fn, line => $ln;
186 0 next;
187 }
188 0 $options{$name}[1] = $default;
189 }
190  
191 0 foreach my $option ($self->options)
192 0 { my $name = $option->name;
193 0 ▶ next if defined $options{$name}[1];
Branch: 1 branch
BranchTrueFalseTotal
if defined $options{$name}[1] 0 0 0
194  
195 0 my ($fn, $ln) = $option->where;
196 0 warning __x"no default for option {name} defined in {file} line {line}"
197 , name => $name, file => $fn, line => $ln;
198  
199 0 my $default = $options{$name}[1] =
200 OODoc::Text::Default->new
201 ( name => $name, value => 'undef'
202 , subroutine => $self, linenr => $ln
203 );
204  
205 0 $self->default($default);
206 }
207  
208 0 \%options;
209 }
210  
211 1 1;
« blib/lib/OODoc/Format/Pod.pm ↑ Summary blib/lib/OODoc/Text/Subroutine.pm »