lib/Perl/PrereqScanner/NotQuiteLite/Context.pm

filter: Statementstmt 89.2% 208 / 233 Branchbran 77.5% 107 / 138 Conditioncond 50.0% 6 / 12 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 87.7% 50 / 57 Podpod 25.5% 12 / 47 totaltotal 77.9% 386 / 495 SCAR 47.5
CC
85
Cov
84%
token_expects_fh_list
20.0
remove_keywords
20.0
_object
11.0
CRAP 115.6
« blib/lib/Perl/PrereqScanner/NotQuiteLite/Parser/ObjectPad.pm ↑ Summary blib/lib/Perl/PrereqScanner/NotQuiteLite/Parser/Moose.pm »
1 package Perl::PrereqScanner::NotQuiteLite::Context;
2  
3 96 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 96 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 96 ▶use CPAN::Meta::Requirements;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 96 ▶use Regexp::Trie;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 96 ▶use Perl::PrereqScanner::NotQuiteLite::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 96 my %defined_keywords = _keywords();
10  
11 96 my %default_op_keywords = map {$_ => 1} qw(
12 x eq ne and or xor cmp ge gt le lt not
13 );
14  
15 96 my %default_conditional_keywords = map {$_ => 1} qw(
16 if elsif unless else
17 );
18  
19 96 my %default_expects_expr_block = map {$_ => 1} qw(
20 if elsif unless given when
21 for foreach while until
22 );
23  
24 96 my %default_expects_block_list = map {$_ => 1} qw(
25 map grep sort
26 );
27  
28 96 my %default_expects_fh_list = map {$_ => 1} qw(
29 print printf say
30 );
31  
32 96 my %default_expects_fh_or_block_list = (
33 %default_expects_block_list,
34 %default_expects_fh_list,
35 );
36  
37 96 my %default_expects_block = map {$_ => 1} qw(
38 else default
39 eval sub do while until continue
40 BEGIN END INIT CHECK
41 if elsif unless given when
42 for foreach while until
43 map grep sort
44 );
45  
46 96 my %default_expects_word = map {$_ => 1} qw(
47 use require no sub
48 );
49  
50 96 my %enables_utf8 = map {$_ => 1} qw(
51 utf8
52 Mojo::Base
53 Mojo::Base::Che
54 );
55  
56 96 my %new_keyword_since = (
57 say => '5.010',
58 state => '5.010',
59 given => '5.010',
60 when => '5.010',
61 default => '5.010',
62 );
63  
64 96 my $default_g_re_prototype = qr{\G(\([^\)]*?\))};
65  
66 sub new {
67 750 ▶ my ($class, %args) = @_;
Subroutine new: called CC=8 SCAR=20.8
Pod documented
68  
69 my %context = (
70 requires => CPAN::Meta::Requirements->new,
71 noes => CPAN::Meta::Requirements->new,
72 file => $args{file},
73 verbose => $args{verbose},
74 optional => $args{optional},
75 750 stash => {},
76 );
77  
78 750 ▶ if ($args{suggests} or $args{recommends}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"suggests"} or $args{"recommends"}) 148 602 750
Condition66%2/3
$args{"suggests"} or $args{"recommends"}
l!l&&r!l&&!r
1480602
MC/DC50%1/2
$args{"suggests"} or $args{"recommends"}
$args{"suggests"} $args{"recommends"}
Truth table66%2/3
A or B
A= $args{"suggests"}B= $args{"recommends"}
ABresult
1X1
011
000
79 148 $context{recommends} = CPAN::Meta::Requirements->new;
80 }
81 750 ▶ if ($args{suggests}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"suggests"}) 148 602 750
82 148 $context{suggests} = CPAN::Meta::Requirements->new;
83 }
84 750 ▶ if ($args{perl_minimum_version}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"perl_minimum_version"}) 83 667 750
85 83 $context{perl} = CPAN::Meta::Requirements->new;
86 }
87 750 for my $type (qw/use no method keyword sub/) {
88 3750 ▶ if (exists $args{_}{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"_"}{$type}) 2991 759 3750
89 2991 for my $key (keys %{$args{_}{$type}}) {
90 135927 $context{$type}{$key} = [@{$args{_}{$type}{$key}}];
91 }
92 }
93 }
94  
95 750 bless \%context, $class;
96 }
97  
98 38 ▶sub stash { shift->{stash} }
Subroutine stash: called CC=1 SCAR=0.0
Pod undocumented
99  
100 sub register_keyword_parser {
101 429 ▶ my ($self, $keyword, $parser_info) = @_;
Subroutine register_keyword_parser: called CC=1 SCAR=0.0
Pod documented
102 429 $self->{keyword}{$keyword} = $parser_info;
103 429 $self->{defined_keywords}{$keyword} = 0;
104 }
105  
106 sub remove_keyword_parser {
107 2 ▶ my ($self, $keyword) = @_;
Subroutine remove_keyword_parser: called CC=2 SCAR=7.0
Pod documented
108 2 delete $self->{keyword}{$keyword};
109 2 ▶ delete $self->{keyword} if !%{$self->{keyword}};
Branch: 1 branch
BranchTrueFalseTotal
unless %{$self->{"keyword"};} 0 2 2
110 2 delete $self->{defined_keywords}{$keyword};
111 }
112  
113 sub register_method_parser {
114 2 ▶ my ($self, $method, $parser_info) = @_;
Subroutine register_method_parser: called CC=1 SCAR=0.0
Pod documented
115 2 $self->{method}{$method} = $parser_info;
116 }
117  
118 96 *register_keyword = \&register_keyword_parser;
119 96 *remove_keyword = \&remove_keyword_parser;
120 96 *register_method = \&register_method_parser;
121  
122 sub register_sub_parser {
123 195 ▶ my ($self, $keyword, $parser_info) = @_;
Subroutine register_sub_parser: called CC=1 SCAR=0.0
Pod documented
124 195 $self->{sub}{$keyword} = $parser_info;
125 195 $self->{defined_keywords}{$keyword} = 0;
126 }
127  
128 596 ▶sub requires { shift->{requires} }
Subroutine requires: called CC=1 SCAR=0.0
Pod documented
129 116 ▶sub recommends { shift->_optional('recommends') }
Subroutine recommends: called CC=1 SCAR=0.0
Pod undocumented
130 146 ▶sub suggests { shift->_optional('suggests') }
Subroutine suggests: called CC=1 SCAR=0.0
Pod documented
131 10 ▶sub noes { shift->{noes} }
Subroutine noes: called CC=1 SCAR=0.0
Pod undocumented
132  
133 sub _optional {
134 262 ▶ my ($self, $key) = @_;
Subroutine _optional: called CC=6 SCAR=20.3
135 262 ▶ my $optional = $self->{$key} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $optional = $self->{$key} or return 0 262 262
136  
137 # no need to recommend/suggest what are listed as requires
138 262 ▶ if (my $requires = $self->{requires}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $requires = $self->{"requires"}) 262 0 262
139 262 my $hash = $optional->as_string_hash;
140 262 for my $module (keys %$hash) {
141 102 ▶ if (defined $requires->requirements_for_module($module) and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $requires->requirements_for_module($module) and $requires->accepts_module($module, $hash->{$module})) 0 102 102
Condition33%1/3
defined $requires->requirements_for_module($module) and $requires->accepts_module($module, $hash->{$module})
!ll&&!rl&&r
10200
MC/DC0%0/2
defined $requires->requirements_for_module($module) and $requires->accepts_module($module, $hash->{$module})
defined $requires->requirements_for_module($module) $requires->accepts_module($module, $hash->{$module})
Truth table33%1/3
A and B
A= defined $requires->requirements_for_module($module)B= $requires->accepts_module($module, $hash->{$module})
ABresult
0X0
100
111
142 $requires->accepts_module($module, $hash->{$module})
143 ) {
144 0 $optional->clear_requirement($module);
145 }
146 }
147 }
148 262 $optional;
149 }
150  
151 sub add {
152 1190 ▶ my $self = shift;
Subroutine add: called CC=2 SCAR=6.9
Pod documented
153 1190 ▶ if ($self->{optional}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'optional'}) { } 9 1181 1190
154 9 $self->_add('suggests', @_);
155 } else {
156 1181 $self->_add('requires', @_);
157 }
158 }
159  
160 sub add_recommendation {
161 29 ▶ shift->_add('recommends', @_);
Subroutine add_recommendation: called CC=1 SCAR=0.0
Pod undocumented
162 }
163  
164 sub add_suggestion {
165 8 ▶ shift->_add('suggests', @_);
Subroutine add_suggestion: called CC=1 SCAR=0.0
Pod undocumented
166 }
167  
168 sub add_conditional {
169 89 ▶ shift->_add('conditional', @_);
Subroutine add_conditional: called CC=1 SCAR=0.0
Pod undocumented
170 }
171  
172 sub add_no {
173 31 ▶ shift->_add('noes', @_);
Subroutine add_no: called CC=1 SCAR=0.0
Pod undocumented
174 }
175  
176 sub add_perl {
177 198 ▶ my ($self, $perl, $reason) = @_;
Subroutine add_perl: called CC=2 SCAR=6.9
Pod undocumented
178 198 ▶ return unless $self->{perl};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"perl"} 109 89 198
179 89 $self->_add('perl', 'perl', $perl);
180 89 $self->{perl_minimum_version}{$reason} = $perl;
181 }
182  
183 sub _add {
184 1436 ▶ my ($self, $type, $module, $version) = @_;
Subroutine _add: called CC=6 SCAR=19.1
185 1436 ▶ return unless is_module_name($module);
Branch: 1 branch
BranchTrueFalseTotal
unless is_module_name($module) 1 1435 1436
186  
187 1435 ▶ my $CMR = $self->_object($type) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $CMR = $self->_object($type) or return 17 1418 1435
188 1418 ▶ $version = 0 unless defined $version;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version 6 1412 1418
189 1418 ▶ if ($self->{verbose}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"verbose"}) 0 1418 1418
190 0 ▶ if (!defined $CMR->requirements_for_module($module)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $CMR->requirements_for_module($module)) 0 0 0
191 0 print STDERR " found $module $version ($type)\n";
192 }
193 }
194 1418 $CMR->add_minimum($module, "$version");
195 }
196  
197 sub has_added {
198 0 ▶ shift->_has_added('requires', @_);
Subroutine has_added: not called CC=1 SCAR=6.9
Pod documented
199 }
200  
201 sub has_added_recommendation {
202 0 ▶ shift->_has_added('recommends', @_);
Subroutine has_added_recommendation: not called CC=1 SCAR=6.9
Pod undocumented
203 }
204  
205 sub has_added_suggestion {
206 0 ▶ shift->_has_added('suggests', @_);
Subroutine has_added_suggestion: not called CC=1 SCAR=6.9
Pod undocumented
207 }
208  
209 sub has_added_conditional {
210 12 ▶ shift->_has_added('conditional', @_);
Subroutine has_added_conditional: called CC=1 SCAR=0.0
Pod undocumented
211 }
212  
213 sub has_added_no {
214 0 ▶ shift->_has_added('no', @_);
Subroutine has_added_no: not called CC=1 SCAR=6.9
Pod undocumented
215 }
216  
217 sub _has_added {
218 12 ▶ my ($self, $type, $module) = @_;
Subroutine _has_added: called CC=4 SCAR=13.9
219 12 ▶ return unless is_module_name($module);
Branch: 1 branch
BranchTrueFalseTotal
unless is_module_name($module) 0 12 12
220  
221 12 ▶ my $CMR = $self->_object($type) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $CMR = $self->_object($type) or return 1 11 12
222 11 ▶ defined $CMR->requirements_for_module($module) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $CMR->requirements_for_module($module) ? : 10 1 11
223 }
224  
225 sub _object {
226 2114 ▶ my ($self, $key) = @_;
Subroutine _object: called CC=11 SCAR=24.0
227 2114 ▶ if ($self->{eval}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->{'eval'}) { } 42 2072 2114
elsif ($self->{'force_cond'}) { } 7 2065 2072
elsif ($key and $key eq 'conditional') { } 87 1978 2065
elsif (not $key) { } 663 1315 1978
228 42 $key = 'suggests';
229 } elsif ($self->{force_cond}) {
230 7 $key = 'recommends';
231 ▶ } elsif ($key && $key eq 'conditional') {
Condition100%3/3
$key and $key eq "conditional"
!ll&&!rl&&r
663131587
MC/DC100%2/2
$key and $key eq "conditional"
$key $key eq "conditional"
Truth table100%3/3
A and B
A= $keyB= $key eq "conditional"
ABresult
0X0
100
111
232 87 ▶ if ($self->{cond}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'cond'}) { } 16 71 87
elsif (grep {$_->[0] eq '{' and $_->[2] ne 'BEGIN';} @{$self->{'stack'} or [];}) { } 17 54 71
233 16 $key = 'recommends';
234 25 ▶ } elsif (grep {$_->[0] eq '{' and $_->[2] ne 'BEGIN'} @{$self->{stack} || []}) {
Branch: 2 branches
BranchTrueFalseTotal
$_->[0] eq "{" and $_->[2] ne "BEGIN" 25 0 25
$self->{"stack"} or [] 0 71 71
235 17 $key = 'recommends';
236 } else {
237 54 $key = 'requires';
238 }
239 } elsif (!$key) {
240 663 $key = 'requires';
241 }
242 2114 ▶ $self->{$key} or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->{$key} or return 20 2094 2114
243 }
244  
245 sub has_callbacks {
246 0 ▶ my ($self, $type) = @_;
Subroutine has_callbacks: not called CC=1 SCAR=6.9
Pod documented
247 0 exists $self->{$type};
248 }
249  
250 sub has_callback_for {
251 872 ▶ my ($self, $type, $name) = @_;
Subroutine has_callback_for: called CC=1 SCAR=0.0
Pod documented
252 872 exists $self->{$type}{$name};
253 }
254  
255 sub run_callback_for {
256 667 ▶ my ($self, $type, $name, @args) = @_;
Subroutine run_callback_for: called CC=2 SCAR=6.9
Pod documented
257 667 ▶ return unless $self->_object;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_object 2 665 667
258 665 my ($parser, $method, @cb_args) = @{$self->{$type}{$name}};
259 665 $parser->$method($self, @cb_args, @args);
260 }
261  
262 sub prototype_re {
263 1602 ▶ my $self = shift;
Subroutine prototype_re: called CC=3 SCAR=11.0
Pod undocumented
264 1602 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 102 1500 1602
265 102 $self->{prototype_re} = shift;
266 }
267 1602 ▶ return $default_g_re_prototype unless exists $self->{prototype_re};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"prototype_re"} 1425 177 1602
268 177 $self->{prototype_re};
269 }
270  
271 sub quotelike_re {
272 206 ▶ my $self = shift;
Subroutine quotelike_re: called CC=2 SCAR=6.9
Pod undocumented
273 206 ▶ return qr/qq?/ unless exists $self->{quotelike_re};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"quotelike_re"} 205 1 206
274 1 $self->{quotelike_re};
275 }
276  
277 sub register_quotelike_keywords {
278 1 ▶ my ($self, @keywords) = @_;
Subroutine register_quotelike_keywords: called CC=4 SCAR=13.9
Pod undocumented
279 1 push @{$self->{quotelike}}, @keywords;
280 1 $self->{defined_keywords}{$_} = 0 for @keywords;
281  
282 1 my $trie = Regexp::Trie->new;
283 1 ▶ $trie->add($_) for 'q', 'qq', @{$self->{quotelike} || []};
Branch: 1 branch
BranchTrueFalseTotal
$self->{"quotelike"} or [] 0 1 1
284 1 $self->{quotelike_re} = $trie->regexp;
285 }
286  
287 sub token_expects_block_list {
288 665 ▶ my ($self, $token) = @_;
Subroutine token_expects_block_list: called CC=4 SCAR=17.1
Pod undocumented
289 665 ▶ return 1 if exists $default_expects_block_list{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $default_expects_block_list{$token} 26 639 665
290 639 ▶ return 0 if !exists $self->{expects_block_list};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"expects_block_list"} 639 0 639
291 0 ▶ return 1 if exists $self->{expects_block_list}{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"expects_block_list"}{$token} 0 0 0
292 0 return 0;
293 }
294  
295 sub token_expects_fh_list {
296 0 ▶ my ($self, $token) = @_;
Subroutine token_expects_fh_list: not called CC=4 SCAR=30.0
Pod undocumented
297 0 ▶ return 1 if exists $default_expects_fh_list{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $default_expects_fh_list{$token} 0 0 0
298 0 ▶ return 0 if !exists $self->{expects_fh_list};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"expects_fh_list"} 0 0 0
299 0 ▶ return 1 if exists $self->{expects_fh_list}{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"expects_fh_list"}{$token} 0 0 0
300 0 return 0;
301 }
302  
303 sub token_expects_fh_or_block_list {
304 18 ▶ my ($self, $token) = @_;
Subroutine token_expects_fh_or_block_list: called CC=4 SCAR=17.1
Pod undocumented
305 18 ▶ return 1 if exists $default_expects_fh_or_block_list{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $default_expects_fh_or_block_list{$token} 15 3 18
306 3 ▶ return 0 if !exists $self->{expects_fh_or_block_list};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"expects_fh_or_block_list"} 3 0 3
307 0 ▶ return 1 if exists $self->{expects_fh_or_block_list}{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"expects_fh_or_block_list"}{$token} 0 0 0
308 0 return 0;
309 }
310  
311 sub token_expects_expr_block {
312 568 ▶ my ($self, $token) = @_;
Subroutine token_expects_expr_block: called CC=4 SCAR=17.1
Pod undocumented
313 568 ▶ return 1 if exists $default_expects_expr_block{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $default_expects_expr_block{$token} 212 356 568
314 356 ▶ return 0 if !exists $self->{expects_expr_block};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"expects_expr_block"} 356 0 356
315 0 ▶ return 1 if exists $self->{expects_expr_block}{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"expects_expr_block"}{$token} 0 0 0
316 0 return 0;
317 }
318  
319 sub token_expects_block {
320 29664 ▶ my ($self, $token) = @_;
Subroutine token_expects_block: called CC=4 SCAR=13.9
Pod undocumented
321 29664 ▶ return 1 if exists $default_expects_block{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $default_expects_block{$token} 2399 27265 29664
322 27265 ▶ return 0 if !exists $self->{expects_block};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"expects_block"} 24866 2399 27265
323 2399 ▶ return 1 if exists $self->{expects_block}{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"expects_block"}{$token} 404 1995 2399
324 1995 return 0;
325 }
326  
327 sub token_expects_word {
328 2726 ▶ my ($self, $token) = @_;
Subroutine token_expects_word: called CC=4 SCAR=13.9
Pod undocumented
329 2726 ▶ return 1 if exists $default_expects_word{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $default_expects_word{$token} 1053 1673 2726
330 1673 ▶ return 0 if !exists $self->{expects_word};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"expects_word"} 1340 333 1673
331 333 ▶ return 1 if exists $self->{expects_word}{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"expects_word"}{$token} 172 161 333
332 161 return 0;
333 }
334  
335 sub token_is_conditional {
336 16 ▶ my ($self, $token) = @_;
Subroutine token_is_conditional: called CC=4 SCAR=17.1
Pod undocumented
337 16 ▶ return 1 if exists $default_conditional_keywords{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $default_conditional_keywords{$token} 2 14 16
338 14 ▶ return 0 if !exists $self->{is_conditional_keyword};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"is_conditional_keyword"} 14 0 14
339 0 ▶ return 1 if exists $self->{is_conditional_keyword}{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"is_conditional_keyword"}{$token} 0 0 0
340 0 return 0;
341 }
342  
343 sub token_is_keyword {
344 5801 ▶ my ($self, $token) = @_;
Subroutine token_is_keyword: called CC=4 SCAR=13.9
Pod undocumented
345 5801 ▶ return 1 if exists $defined_keywords{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $defined_keywords{$token} 3353 2448 5801
346 2448 ▶ return 0 if !exists $self->{defined_keywords};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"defined_keywords"} 1598 850 2448
347 850 ▶ return 1 if exists $self->{defined_keywords}{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"defined_keywords"}{$token} 316 534 850
348 534 return 0;
349 }
350  
351 sub token_is_op_keyword {
352 3649 ▶ my ($self, $token) = @_;
Subroutine token_is_op_keyword: called CC=4 SCAR=13.9
Pod undocumented
353 3649 ▶ return 1 if exists $default_op_keywords{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $default_op_keywords{$token} 163 3486 3649
354 3486 ▶ return 0 if !exists $self->{defined_op_keywords};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"defined_op_keywords"} 3458 28 3486
355 28 ▶ return 1 if exists $self->{defined_op_keywords}{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"defined_op_keywords"}{$token} 1 27 28
356 27 return 0;
357 }
358  
359 sub check_new_keyword {
360 3485 ▶ my ($self, $token) = @_;
Subroutine check_new_keyword: called CC=2 SCAR=6.9
Pod undocumented
361 3485 ▶ if (exists $new_keyword_since{$token}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $new_keyword_since{$token}) 27 3458 3485
362 27 $self->add_perl($new_keyword_since{$token}, $token);
363 }
364 }
365  
366 sub register_keywords {
367 4 ▶ my ($self, @keywords) = @_;
Subroutine register_keywords: called CC=2 SCAR=6.9
Pod undocumented
368 4 for my $keyword (@keywords) {
369 6 $self->{defined_keywords}{$keyword} = 0;
370 }
371 }
372  
373 sub register_op_keywords {
374 1 ▶ my ($self, @keywords) = @_;
Subroutine register_op_keywords: called CC=2 SCAR=6.9
Pod undocumented
375 1 for my $keyword (@keywords) {
376 1 $self->{defined_op_keywords}{$keyword} = 0;
377 }
378 }
379  
380 sub remove_keywords {
381 0 ▶ my ($self, @keywords) = @_;
Subroutine remove_keywords: not called CC=4 SCAR=30.0
Pod undocumented
382 0 for my $keyword (@keywords) {
383 0 ▶ delete $self->{defined_keywords}{$keyword} if exists $self->{defined_keywords}{$keyword} and !$self->{defined_keywords}{$keyword};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"defined_keywords"}{$keyword} and not $self->{"defined_keywords"}{$keyword} 0 0 0
Condition0%0/3
exists $self->{"defined_keywords"}{$keyword} and not $self->{"defined_keywords"}{$keyword}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"defined_keywords"}{$keyword} and not $self->{"defined_keywords"}{$keyword}
exists $self->{"defined_keywords"}{$keyword} not $self->{"defined_keywords"}{$keyword}
Truth table0%0/3
A and not(B)
A= exists $self->{"defined_keywords"}{$keyword}B= not $self->{"defined_keywords"}{$keyword}
ABresult
0X0
100
111
384 }
385 }
386  
387 sub register_sub_keywords {
388 103 ▶ my ($self, @keywords) = @_;
Subroutine register_sub_keywords: called CC=2 SCAR=6.9
Pod undocumented
389 103 for my $keyword (@keywords) {
390 367 $self->{defines_sub}{$keyword} = 1;
391 367 $self->{expects_block}{$keyword} = 1;
392 367 $self->{expects_word}{$keyword} = 1;
393 367 $self->{defined_keywords}{$keyword} = 0;
394 }
395 }
396  
397 sub token_defines_sub {
398 637 ▶ my ($self, $token) = @_;
Subroutine token_defines_sub: called CC=4 SCAR=13.9
Pod undocumented
399 637 ▶ return 1 if $token eq 'sub';
Branch: 1 branch
BranchTrueFalseTotal
if $token eq "sub" 148 489 637
400 489 ▶ return 0 if !exists $self->{defines_sub};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"defines_sub"} 316 173 489
401 173 ▶ return 1 if exists $self->{defines_sub}{$token};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"defines_sub"}{$token} 168 5 173
402 5 return 0;
403 }
404  
405 sub enables_utf8 {
406 717 ▶ my ($self, $module) = @_;
Subroutine enables_utf8: called CC=2 SCAR=6.9
Pod undocumented
407 717 ▶ exists $enables_utf8{$module} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $enables_utf8{$module} ? : 18 699 717
408 }
409  
410 sub add_package {
411 127 ▶ my ($self, $package) = @_;
Subroutine add_package: called CC=1 SCAR=0.0
Pod undocumented
412 127 $self->{packages}{$package} = 1;
413 }
414  
415 sub packages {
416 750 ▶ my $self = shift;
Subroutine packages: called CC=2 SCAR=6.9
Pod undocumented
417 750 ▶ keys %{$self->{packages} || {}};
Branch: 1 branch
BranchTrueFalseTotal
$self->{"packages"} or {} 642 108 750
418 }
419  
420 sub remove_inner_packages_from_requirements {
421 750 ▶ my $self = shift;
Subroutine remove_inner_packages_from_requirements: called CC=4 SCAR=13.9
Pod undocumented
422 750 for my $package ($self->packages) {
423 123 for my $rel (qw/requires recommends suggests noes/) {
424 492 ▶ next unless $self->{$rel};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{$rel} 244 248 492
425 248 $self->{$rel}->clear_requirement($package);
426 }
427 }
428 }
429  
430 sub merge_perl {
431 750 ▶ my $self = shift;
Subroutine merge_perl: called CC=3 SCAR=11.0
Pod undocumented
432 750 ▶ return unless $self->{perl};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"perl"} 667 83 750
433  
434 83 my $perl = $self->{requires}->requirements_for_module('perl');
435 83 ▶ if ($self->{perl}->accepts_module('perl', $perl)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'perl'}->accepts_module('perl', $perl)) { } 11 72 83
436 11 delete $self->{perl_minimum_version};
437 } else {
438 72 $self->add(perl => $self->{perl}->requirements_for_module('perl'));
439 }
440 }
441  
442 sub _keywords {(
443 96 ▶ '__FILE__' => 1,
Subroutine _keywords: called CC=1 SCAR=0.0
444 '__LINE__' => 2,
445 '__PACKAGE__' => 3,
446 '__DATA__' => 4,
447 '__END__' => 5,
448 '__SUB__' => 6,
449 AUTOLOAD => 7,
450 BEGIN => 8,
451 UNITCHECK => 9,
452 DESTROY => 10,
453 END => 11,
454 INIT => 12,
455 CHECK => 13,
456 abs => 14,
457 accept => 15,
458 alarm => 16,
459 and => 17,
460 atan2 => 18,
461 bind => 19,
462 binmode => 20,
463 bless => 21,
464 break => 22,
465 caller => 23,
466 chdir => 24,
467 chmod => 25,
468 chomp => 26,
469 chop => 27,
470 chown => 28,
471 chr => 29,
472 chroot => 30,
473 close => 31,
474 closedir => 32,
475 cmp => 33,
476 connect => 34,
477 continue => 35,
478 cos => 36,
479 crypt => 37,
480 dbmclose => 38,
481 dbmopen => 39,
482 default => 40,
483 defined => 41,
484 delete => 42,
485 die => 43,
486 do => 44,
487 dump => 45,
488 each => 46,
489 else => 47,
490 elsif => 48,
491 endgrent => 49,
492 endhostent => 50,
493 endnetent => 51,
494 endprotoent => 52,
495 endpwent => 53,
496 endservent => 54,
497 eof => 55,
498 eq => 56,
499 eval => 57,
500 evalbytes => 58,
501 exec => 59,
502 exists => 60,
503 exit => 61,
504 exp => 62,
505 fc => 63,
506 fcntl => 64,
507 fileno => 65,
508 flock => 66,
509 for => 67,
510 foreach => 68,
511 fork => 69,
512 format => 70,
513 formline => 71,
514 ge => 72,
515 getc => 73,
516 getgrent => 74,
517 getgrgid => 75,
518 getgrnam => 76,
519 gethostbyaddr => 77,
520 gethostbyname => 78,
521 gethostent => 79,
522 getlogin => 80,
523 getnetbyaddr => 81,
524 getnetbyname => 82,
525 getnetent => 83,
526 getpeername => 84,
527 getpgrp => 85,
528 getppid => 86,
529 getpriority => 87,
530 getprotobyname => 88,
531 getprotobynumber => 89,
532 getprotoent => 90,
533 getpwent => 91,
534 getpwnam => 92,
535 getpwuid => 93,
536 getservbyname => 94,
537 getservbyport => 95,
538 getservent => 96,
539 getsockname => 97,
540 getsockopt => 98,
541 given => 99,
542 glob => 100,
543 gmtime => 101,
544 goto => 102,
545 grep => 103,
546 gt => 104,
547 hex => 105,
548 if => 106,
549 index => 107,
550 int => 108,
551 ioctl => 109,
552 join => 110,
553 keys => 111,
554 kill => 112,
555 last => 113,
556 lc => 114,
557 lcfirst => 115,
558 le => 116,
559 length => 117,
560 link => 118,
561 listen => 119,
562 local => 120,
563 localtime => 121,
564 lock => 122,
565 log => 123,
566 lstat => 124,
567 lt => 125,
568 m => 126,
569 map => 127,
570 mkdir => 128,
571 msgctl => 129,
572 msgget => 130,
573 msgrcv => 131,
574 msgsnd => 132,
575 my => 133,
576 ne => 134,
577 next => 135,
578 no => 136,
579 not => 137,
580 oct => 138,
581 open => 139,
582 opendir => 140,
583 or => 141,
584 ord => 142,
585 our => 143,
586 pack => 144,
587 package => 145,
588 pipe => 146,
589 pop => 147,
590 pos => 148,
591 print => 149,
592 printf => 150,
593 prototype => 151,
594 push => 152,
595 q => 153,
596 qq => 154,
597 qr => 155,
598 quotemeta => 156,
599 qw => 157,
600 qx => 158,
601 rand => 159,
602 read => 160,
603 readdir => 161,
604 readline => 162,
605 readlink => 163,
606 readpipe => 164,
607 recv => 165,
608 redo => 166,
609 ref => 167,
610 rename => 168,
611 require => 169,
612 reset => 170,
613 return => 171,
614 reverse => 172,
615 rewinddir => 173,
616 rindex => 174,
617 rmdir => 175,
618 s => 176,
619 say => 177,
620 scalar => 178,
621 seek => 179,
622 seekdir => 180,
623 select => 181,
624 semctl => 182,
625 semget => 183,
626 semop => 184,
627 send => 185,
628 setgrent => 186,
629 sethostent => 187,
630 setnetent => 188,
631 setpgrp => 189,
632 setpriority => 190,
633 setprotoent => 191,
634 setpwent => 192,
635 setservent => 193,
636 setsockopt => 194,
637 shift => 195,
638 shmctl => 196,
639 shmget => 197,
640 shmread => 198,
641 shmwrite => 199,
642 shutdown => 200,
643 sin => 201,
644 sleep => 202,
645 socket => 203,
646 socketpair => 204,
647 sort => 205,
648 splice => 206,
649 split => 207,
650 sprintf => 208,
651 sqrt => 209,
652 srand => 210,
653 stat => 211,
654 state => 212,
655 study => 213,
656 sub => 214,
657 substr => 215,
658 symlink => 216,
659 syscall => 217,
660 sysopen => 218,
661 sysread => 219,
662 sysseek => 220,
663 system => 221,
664 syswrite => 222,
665 tell => 223,
666 telldir => 224,
667 tie => 225,
668 tied => 226,
669 time => 227,
670 times => 228,
671 tr => 229,
672 truncate => 230,
673 uc => 231,
674 ucfirst => 232,
675 umask => 233,
676 undef => 234,
677 unless => 235,
678 unlink => 236,
679 unpack => 237,
680 unshift => 238,
681 untie => 239,
682 until => 240,
683 use => 241,
684 utime => 242,
685 values => 243,
686 vec => 244,
687 wait => 245,
688 waitpid => 246,
689 wantarray => 247,
690 warn => 248,
691 when => 249,
692 while => 250,
693 write => 251,
694 x => 252,
695 xor => 253,
696 y => 254 || 255,
697 )}
698  
699 96 1;
700  
701 __END__
« blib/lib/Perl/PrereqScanner/NotQuiteLite/Parser/ObjectPad.pm ↑ Summary blib/lib/Perl/PrereqScanner/NotQuiteLite/Parser/Moose.pm »