lib/Perl/ToPerl6/Utils.pm

filter: Statementstmt 91.0% 367 / 403 Branchbran 65.4% 165 / 252 Conditioncond 52.5% 42 / 80 MC/DCmcdc 22.4% 11 / 49 Subroutinesub 87.3% 55 / 63 Podpod 100% 39 / 39 totaltotal 76.6% 679 / 886 CC 163 SCAR 25.9
CC
163
Cov
78%
is_in_void_context
132.0
is_perl_builtin_with_zero_and_or_one_arguments
20.0
_is_fatal
17.1
CRAP 13.4
« lib/Perl/ToPerl6/Transformer/Variables/RewriteSigils.pm ↑ Summary lib/Perl/ToPerl6/Annotation.pm »
1 # NOTE: This module is way too large. Please think about adding new
2 # functionality into a P::C::Utils::* module instead.
3  
4 package Perl::ToPerl6::Utils;
5  
6 30 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 30 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 30 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 30 ▶use Carp qw( confess );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 30 ▶use English qw(-no_match_vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 30 ▶use File::Spec qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 30 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 30 ▶use B::Keywords qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 30 ▶use PPI::Token::Quote::Single;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 30 ▶use Perl::ToPerl6::Exception::Fatal::Generic qw{ throw_generic };
Subroutine BEGIN: called CC=1 SCAR=0.0
19 30 ▶use Perl::ToPerl6::Utils::PPI qw< is_ppi_expression_or_generic_statement >;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 30 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 #-----------------------------------------------------------------------------
24 # Exportable symbols here.
25  
26 30 Readonly::Array our @EXPORT_OK => qw(
27 $TRUE
28 $FALSE
29  
30 $TRANSFORMER_NAMESPACE
31  
32 $NECESSITY_HIGHEST
33 $NECESSITY_HIGH
34 $NECESSITY_MEDIUM
35 $NECESSITY_LOW
36 $NECESSITY_LOWEST
37 @NECESSITY_NAMES
38  
39 $DEFAULT_VERBOSITY
40 $DEFAULT_VERBOSITY_WITH_FILE_NAME
41  
42 $COLON
43 $COMMA
44 $DQUOTE
45 $EMPTY
46 $EQUAL
47 $FATCOMMA
48 $PERIOD
49 $PIPE
50 $QUOTE
51 $BACKTICK
52 $SCOLON
53 $SPACE
54 $SLASH
55 $BSLASH
56 $LEFT_PAREN
57 $RIGHT_PAREN
58  
59 all_perl_files
60 find_keywords
61 first_arg
62 hashify
63 interpolate
64 is_assignment_operator
65 is_class_name
66 is_function_call
67 is_hash_key
68 is_in_void_context
69 is_included_module_name
70 is_integer
71 is_label_pointer
72 is_method_call
73 is_package_declaration
74 is_perl_bareword
75 is_perl_builtin
76 is_perl_builtin_with_list_context
77 is_perl_builtin_with_multiple_arguments
78 is_perl_builtin_with_no_arguments
79 is_perl_builtin_with_one_argument
80 is_perl_builtin_with_optional_argument
81 is_perl_builtin_with_zero_and_or_one_arguments
82 is_perl_filehandle
83 is_perl_global
84 is_qualified_name
85 is_script
86 is_subroutine_name
87 is_unchecked_call
88 is_valid_numeric_verbosity
89 parse_arg_list
90 transformer_long_name
91 transformer_short_name
92 precedence_of
93 necessity_to_number
94 shebang_line
95 split_nodes_on_comma
96 verbosity_to_format
97 words_from_string
98 );
99  
100  
101 # Note: this is deprecated. This should also violate ProhibitAutomaticExportation,
102 # but at the moment, we aren't smart enough to deal with Readonly variables.
103 30 Readonly::Array our @EXPORT => @EXPORT_OK;
104  
105  
106 30 Readonly::Hash our %EXPORT_TAGS => (
107 all => [ @EXPORT_OK ],
108 booleans => [ qw{ $TRUE $FALSE } ],
109 severities => [
110 qw{
111 $NECESSITY_HIGHEST
112 $NECESSITY_HIGH
113 $NECESSITY_MEDIUM
114 $NECESSITY_LOW
115 $NECESSITY_LOWEST
116 @NECESSITY_NAMES
117 }
118 ],
119 characters => [
120 qw{
121 $COLON
122 $COMMA
123 $DQUOTE
124 $EMPTY
125 $EQUAL
126 $FATCOMMA
127 $PERIOD
128 $PIPE
129 $QUOTE
130 $BACKTICK
131 $SCOLON
132 $SPACE
133 $SLASH
134 $BSLASH
135 $LEFT_PAREN
136 $RIGHT_PAREN
137 }
138 ],
139 classification => [
140 qw{
141 is_assignment_operator
142 is_class_name
143 is_function_call
144 is_hash_key
145 is_included_module_name
146 is_integer
147 is_label_pointer
148 is_method_call
149 is_package_declaration
150 is_perl_bareword
151 is_perl_builtin
152 is_perl_filehandle
153 is_perl_global
154 is_perl_builtin_with_list_context
155 is_perl_builtin_with_multiple_arguments
156 is_perl_builtin_with_no_arguments
157 is_perl_builtin_with_one_argument
158 is_perl_builtin_with_optional_argument
159 is_perl_builtin_with_zero_and_or_one_arguments
160 is_qualified_name
161 is_script
162 is_subroutine_name
163 is_unchecked_call
164 is_valid_numeric_verbosity
165 }
166 ],
167 data_conversion => [ qw{ hashify words_from_string interpolate } ],
168 ppi => [ qw{ first_arg parse_arg_list } ],
169 internal_lookup => [ qw{ necessity_to_number verbosity_to_format } ],
170 language => [ qw{ precedence_of } ],
171 deprecated => [ qw{ find_keywords } ],
172 );
173  
174 #-----------------------------------------------------------------------------
175  
176 30 Readonly::Scalar our $TRANSFORMER_NAMESPACE => 'Perl::ToPerl6::Transformer';
177  
178 #-----------------------------------------------------------------------------
179  
180 30 Readonly::Scalar our $NECESSITY_HIGHEST => 5;
181 30 Readonly::Scalar our $NECESSITY_HIGH => 4;
182 30 Readonly::Scalar our $NECESSITY_MEDIUM => 3;
183 30 Readonly::Scalar our $NECESSITY_LOW => 2;
184 30 Readonly::Scalar our $NECESSITY_LOWEST => 1;
185  
186 #-----------------------------------------------------------------------------
187  
188 30 Readonly::Scalar our $COMMA => q{,};
189 30 Readonly::Scalar our $EQUAL => q{=};
190 30 Readonly::Scalar our $FATCOMMA => q{=>};
191 30 Readonly::Scalar our $COLON => q{:};
192 30 Readonly::Scalar our $SCOLON => q{;};
193 30 Readonly::Scalar our $QUOTE => q{'};
194 30 Readonly::Scalar our $DQUOTE => q{"};
195 30 Readonly::Scalar our $BACKTICK => q{`};
196 30 Readonly::Scalar our $PERIOD => q{.};
197 30 Readonly::Scalar our $PIPE => q{|};
198 30 Readonly::Scalar our $SPACE => q{ };
199 30 Readonly::Scalar our $SLASH => q{/};
200 30 Readonly::Scalar our $BSLASH => q{\\};
201 30 Readonly::Scalar our $LEFT_PAREN => q{(};
202 30 Readonly::Scalar our $RIGHT_PAREN => q{)};
203 30 Readonly::Scalar our $EMPTY => q{};
204 30 Readonly::Scalar our $TRUE => 1;
205 30 Readonly::Scalar our $FALSE => 0;
206  
207 #-----------------------------------------------------------------------------
208  
209 #TODO: Should this include punctuations vars?
210  
211  
212  
213 #-----------------------------------------------------------------------------
214  
215 30 Readonly::Hash my %PRECEDENCE_OF => (
216 '->' => 1,
217 '++' => 2,
218 '--' => 2,
219 '**' => 3,
220 '!' => 4,
221 '~' => 4,
222 '\\' => 4,
223 '=~' => 5,
224 '!~' => 5,
225 '*' => 6,
226 '/' => 6,
227 '%' => 6,
228 'x' => 6,
229 '+' => 7,
230 '-' => 7,
231 '.' => 7,
232 '<<' => 8,
233 '>>' => 8,
234 '-R' => 9,
235 '-W' => 9,
236 '-X' => 9,
237 '-r' => 9,
238 '-w' => 9,
239 '-x' => 9,
240 '-e' => 9,
241 '-O' => 9,
242 '-o' => 9,
243 '-z' => 9,
244 '-s' => 9,
245 '-M' => 9,
246 '-A' => 9,
247 '-C' => 9,
248 '-S' => 9,
249 '-c' => 9,
250 '-b' => 9,
251 '-f' => 9,
252 '-d' => 9,
253 '-p' => 9,
254 '-l' => 9,
255 '-u' => 9,
256 '-g' => 9,
257 '-k' => 9,
258 '-t' => 9,
259 '-T' => 9,
260 '-B' => 9,
261 '<' => 10,
262 '>' => 10,
263 '<=' => 10,
264 '>=' => 10,
265 'lt' => 10,
266 'gt' => 10,
267 'le' => 10,
268 'ge' => 10,
269 '==' => 11,
270 '!=' => 11,
271 '<=>' => 11,
272 'eq' => 11,
273 'ne' => 11,
274 'cmp' => 11,
275 '~~' => 11,
276 '&' => 12,
277 '|' => 13,
278 '^' => 13,
279 '&&' => 14,
280 '//' => 15,
281 '||' => 15,
282 '..' => 16,
283 '...' => 17,
284 '?' => 18,
285 ':' => 18,
286 '=' => 19,
287 '+=' => 19,
288 '-=' => 19,
289 '*=' => 19,
290 '/=' => 19,
291 '%=' => 19,
292 '||=' => 19,
293 '&&=' => 19,
294 '|=' => 19,
295 '&=' => 19,
296 '**=' => 19,
297 'x=' => 19,
298 '.=' => 19,
299 '^=' => 19,
300 '<<=' => 19,
301 '>>=' => 19,
302 '//=' => 19,
303 ',' => 20,
304 '=>' => 20,
305 'not' => 22,
306 'and' => 23,
307 'or' => 24,
308 'xor' => 24,
309 );
310  
311 ## use mogrify
312  
313 30 Readonly::Scalar my $MIN_PRECEDENCE_TO_TERMINATE_PARENLESS_ARG_LIST =>
314 precedence_of( 'not' );
315  
316 #-----------------------------------------------------------------------------
317  
318 3376 ▶sub hashify {
Subroutine hashify: called CC=1 SCAR=0.0
Pod documented
319 3376 return map { $_ => 1 } @_;
320 }
321  
322 #-----------------------------------------------------------------------------
323  
324 23 ▶sub interpolate {
Subroutine interpolate: called CC=2 SCAR=7.2
Pod documented
325 23 my ( $literal ) = @_;
326 23 ▶ return eval "\"$literal\"" || confess $EVAL_ERROR;
Condition50%1/2
eval qq["$literal"] || confess($Perl::ToPerl6::Utils::EVAL_ERROR)
l!l
230
MC/DC0%0/1
eval qq["$literal"] || confess($Perl::ToPerl6::Utils::EVAL_ERROR)
eval qq["$literal"]
Truth table50%1/2
A
A= eval qq["$literal"]
Aresult
11
00
327 }
328  
329 #-----------------------------------------------------------------------------
330  
331 5 ▶sub find_keywords {
Subroutine find_keywords: called CC=3 SCAR=11.0
Pod documented
332 5 my ( $doc, $keyword ) = @_;
333 5 my $nodes_ref = $doc->find('PPI::Token::Word');
334 5 ▶ return if !$nodes_ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $nodes_ref 1 4 5
335 4 my @matches = grep { $_ eq $keyword } @{$nodes_ref};
336 4 ▶ return @matches ? \@matches : undef;
Branch: 1 branch
BranchTrueFalseTotal
@matches ? : 3 1 4
337 }
338  
339 #-----------------------------------------------------------------------------
340  
341 35 ▶sub _name_for_sub_or_stringified_element {
Subroutine _name_for_sub_or_stringified_element: called CC=3 SCAR=11.0
342 35 my $elem = shift;
343  
344 35 ▶ if ( blessed $elem and $elem->isa('PPI::Statement::Sub') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($elem) and $elem->isa("PPI::Statement::Sub")) 2 33 35
Condition100%3/3
builtin::blessed($elem) and $elem->isa("PPI::Statement::Sub")
!ll&&!rl&&r
2312
MC/DC100%2/2
builtin::blessed($elem) and $elem->isa("PPI::Statement::Sub")
builtin::blessed($elem) $elem->isa("PPI::Statement::Sub")
Truth table100%3/3
A and B
A= builtin::blessed($elem)B= $elem->isa("PPI::Statement::Sub")
ABresult
0X0
100
111
345 2 return $elem->name();
346 }
347  
348 33 return "$elem";
349 }
350  
351 #-----------------------------------------------------------------------------
352  
353 30 Readonly::Hash my %BUILTINS => hashify( @B::Keywords::Functions );
354  
355 4 ▶sub is_perl_builtin {
Subroutine is_perl_builtin: called CC=2 SCAR=7.1
Pod documented
356 4 my $elem = shift;
357 4 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 4 4
358  
359 4 return exists $BUILTINS{ _name_for_sub_or_stringified_element($elem) };
360 }
361  
362 #-----------------------------------------------------------------------------
363  
364 30 Readonly::Hash my %BAREWORDS => hashify( @B::Keywords::Barewords );
365  
366 16 ▶sub is_perl_bareword {
Subroutine is_perl_bareword: called CC=2 SCAR=7.1
Pod documented
367 16 my $elem = shift;
368 16 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 16 16
369  
370 16 return exists $BAREWORDS{ _name_for_sub_or_stringified_element($elem) };
371 }
372  
373 #-----------------------------------------------------------------------------
374  
375 30 ▶sub _build_globals_without_sigils {
Subroutine _build_globals_without_sigils: called CC=2 SCAR=6.9
376 # B::Keywords as of 1.08 forgot $\
377 my @globals =
378 30 map { substr $_, 1 }
379 @B::Keywords::Arrays,
380 @B::Keywords::Hashes,
381 @B::Keywords::Scalars,
382 '$\\';
383  
384 # Not all of these have sigils
385 30 foreach my $filehandle (@B::Keywords::Filehandles) {
386 270 (my $stripped = $filehandle) =~ s< \A [*] ><>xms;
387 270 push @globals, $stripped;
388 }
389  
390 30 return @globals;
391 }
392  
393 30 Readonly::Array my @GLOBALS_WITHOUT_SIGILS => _build_globals_without_sigils();
394  
395 30 Readonly::Hash my %GLOBALS => hashify( @GLOBALS_WITHOUT_SIGILS );
396  
397 7 ▶sub is_perl_global {
Subroutine is_perl_global: called CC=2 SCAR=7.0
Pod documented
398 7 my $elem = shift;
399 7 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 7 7
400 7 my $var_name = "$elem"; #Convert Token::Symbol to string
401 7 $var_name =~ s{\A [\$@%*] }{}xms; #Chop off the sigil
402 7 return exists $GLOBALS{ $var_name };
403 }
404  
405 #-----------------------------------------------------------------------------
406  
407 30 Readonly::Hash my %FILEHANDLES => hashify( @B::Keywords::Filehandles );
408  
409 15 ▶sub is_perl_filehandle {
Subroutine is_perl_filehandle: called CC=2 SCAR=7.1
Pod documented
410 15 my $elem = shift;
411 15 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 15 15
412  
413 15 return exists $FILEHANDLES{ _name_for_sub_or_stringified_element($elem) };
414 }
415  
416 ## use mogrify
417 #-----------------------------------------------------------------------------
418  
419 # egrep '=item.*LIST' perlfunc.pod
420 30 Readonly::Hash my %BUILTINS_WHICH_PROVIDE_LIST_CONTEXT =>
421 hashify(
422 qw{
423 chmod
424 chown
425 die
426 exec
427 formline
428 grep
429 import
430 join
431 kill
432 map
433 no
434 open
435 pack
436 print
437 printf
438 push
439 reverse
440 say
441 sort
442 splice
443 sprintf
444 syscall
445 system
446 tie
447 unlink
448 unshift
449 use
450 utime
451 warn
452 },
453 );
454  
455 0 ▶sub is_perl_builtin_with_list_context {
Subroutine is_perl_builtin_with_list_context: not called CC=1 SCAR=6.9
Pod documented
456 0 my $elem = shift;
457  
458 return
459 exists
460 $BUILTINS_WHICH_PROVIDE_LIST_CONTEXT{
461 0 _name_for_sub_or_stringified_element($elem)
462 };
463 }
464  
465 #-----------------------------------------------------------------------------
466  
467 # egrep '=item.*[A-Z],' perlfunc.pod
468 30 Readonly::Hash my %BUILTINS_WHICH_TAKE_MULTIPLE_ARGUMENTS =>
469 hashify(
470 qw{
471 accept
472 atan2
473 bind
474 binmode
475 bless
476 connect
477 crypt
478 dbmopen
479 fcntl
480 flock
481 gethostbyaddr
482 getnetbyaddr
483 getpriority
484 getservbyname
485 getservbyport
486 getsockopt
487 index
488 ioctl
489 link
490 listen
491 mkdir
492 msgctl
493 msgget
494 msgrcv
495 msgsnd
496 open
497 opendir
498 pipe
499 read
500 recv
501 rename
502 rindex
503 seek
504 seekdir
505 select
506 semctl
507 semget
508 semop
509 send
510 setpgrp
511 setpriority
512 setsockopt
513 shmctl
514 shmget
515 shmread
516 shmwrite
517 shutdown
518 socket
519 socketpair
520 splice
521 split
522 substr
523 symlink
524 sysopen
525 sysread
526 sysseek
527 syswrite
528 truncate
529 unpack
530 vec
531 waitpid
532 },
533 keys %BUILTINS_WHICH_PROVIDE_LIST_CONTEXT
534 );
535  
536 0 ▶sub is_perl_builtin_with_multiple_arguments {
Subroutine is_perl_builtin_with_multiple_arguments: not called CC=1 SCAR=6.9
Pod documented
537 0 my $elem = shift;
538  
539 return
540 exists
541 $BUILTINS_WHICH_TAKE_MULTIPLE_ARGUMENTS{
542 0 _name_for_sub_or_stringified_element($elem)
543 };
544 }
545  
546 #-----------------------------------------------------------------------------
547  
548 30 Readonly::Hash my %BUILTINS_WHICH_TAKE_NO_ARGUMENTS =>
549 hashify(
550 qw{
551 endgrent
552 endhostent
553 endnetent
554 endprotoent
555 endpwent
556 endservent
557 fork
558 format
559 getgrent
560 gethostent
561 getlogin
562 getnetent
563 getppid
564 getprotoent
565 getpwent
566 getservent
567 setgrent
568 setpwent
569 split
570 time
571 times
572 wait
573 wantarray
574 }
575 );
576  
577 0 ▶sub is_perl_builtin_with_no_arguments {
Subroutine is_perl_builtin_with_no_arguments: not called CC=1 SCAR=6.9
Pod documented
578 0 my $elem = shift;
579  
580 return
581 exists
582 $BUILTINS_WHICH_TAKE_NO_ARGUMENTS{
583 0 _name_for_sub_or_stringified_element($elem)
584 };
585 }
586  
587 #-----------------------------------------------------------------------------
588  
589 30 Readonly::Hash my %BUILTINS_WHICH_TAKE_ONE_ARGUMENT =>
590 hashify(
591 qw{
592 closedir
593 dbmclose
594 delete
595 each
596 exists
597 fileno
598 getgrgid
599 getgrnam
600 gethostbyname
601 getnetbyname
602 getpeername
603 getpgrp
604 getprotobyname
605 getprotobynumber
606 getpwnam
607 getpwuid
608 getsockname
609 goto
610 keys
611 local
612 prototype
613 readdir
614 readline
615 readpipe
616 rewinddir
617 scalar
618 sethostent
619 setnetent
620 setprotoent
621 setservent
622 telldir
623 tied
624 untie
625 values
626 }
627 );
628  
629 0 ▶sub is_perl_builtin_with_one_argument {
Subroutine is_perl_builtin_with_one_argument: not called CC=1 SCAR=6.9
Pod documented
630 0 my $elem = shift;
631  
632 return
633 exists
634 $BUILTINS_WHICH_TAKE_ONE_ARGUMENT{
635 0 _name_for_sub_or_stringified_element($elem)
636 };
637 }
638  
639 #-----------------------------------------------------------------------------
640  
641 Readonly::Hash my %BUILTINS_WHICH_TAKE_OPTIONAL_ARGUMENT =>
642 hashify(
643 4080 grep { not exists $BUILTINS_WHICH_TAKE_ONE_ARGUMENT{ $_ } }
644 4740 grep { not exists $BUILTINS_WHICH_TAKE_NO_ARGUMENTS{ $_ } }
645 30 grep { not exists $BUILTINS_WHICH_TAKE_MULTIPLE_ARGUMENTS{ $_ } }
646 @B::Keywords::Functions
647 );
648 ## use mogrify
649  
650 0 ▶sub is_perl_builtin_with_optional_argument {
Subroutine is_perl_builtin_with_optional_argument: not called CC=1 SCAR=6.9
Pod documented
651 0 my $elem = shift;
652  
653 return
654 exists
655 $BUILTINS_WHICH_TAKE_OPTIONAL_ARGUMENT{
656 0 _name_for_sub_or_stringified_element($elem)
657 };
658 }
659  
660 #-----------------------------------------------------------------------------
661  
662 0 ▶sub is_perl_builtin_with_zero_and_or_one_arguments {
Subroutine is_perl_builtin_with_zero_and_or_one_arguments: not called CC=4 SCAR=30.0
Pod documented
663 0 my $elem = shift;
664  
665 0 ▶ return if not $elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 0 0
666  
667 0 my $name = _name_for_sub_or_stringified_element($elem);
668  
669 return (
670 exists $BUILTINS_WHICH_TAKE_ONE_ARGUMENT{ $name }
671 or exists $BUILTINS_WHICH_TAKE_NO_ARGUMENTS{ $name }
672 0 ▶ or exists $BUILTINS_WHICH_TAKE_OPTIONAL_ARGUMENT{ $name }
Condition0%0/6
exists $BUILTINS_WHICH_TAKE_ONE_ARGUMENT{$name} || exists $BUILTINS_WHICH_TAKE_NO_ARGUMENTS{$name} || exists $BUILTINS_WHICH_TAKE_OPTIONAL_ARGUMENT{$name}
l!l&&r!l&&!r
000
exists $BUILTINS_WHICH_TAKE_ONE_ARGUMENT{$name} or exists $BUILTINS_WHICH_TAKE_NO_ARGUMENTS{$name}
l!l&&r!l&&!r
000
MC/DC0%0/3
exists $BUILTINS_WHICH_TAKE_ONE_ARGUMENT{$name} || exists $BUILTINS_WHICH_TAKE_NO_ARGUMENTS{$name} || exists $BUILTINS_WHICH_TAKE_OPTIONAL_ARGUMENT{$name}
exists $BUILTINS_WHICH_TAKE_ONE_ARGUMENT{$name} exists $BUILTINS_WHICH_TAKE_NO_ARGUMENTS{$name} exists $BUILTINS_WHICH_TAKE_OPTIONAL_ARGUMENT{$name}
Truth table0%0/4
A or B || C
A= exists $BUILTINS_WHICH_TAKE_ONE_ARGUMENT{$name}B= exists $BUILTINS_WHICH_TAKE_NO_ARGUMENTS{$name}C= exists $BUILTINS_WHICH_TAKE_OPTIONAL_ARGUMENT{$name}
ABCresult
1XX1
01X1
0011
0000
673 );
674 }
675  
676 #-----------------------------------------------------------------------------
677  
678 0 ▶sub is_qualified_name {
Subroutine is_qualified_name: not called CC=2 SCAR=17.9
Pod documented
679 0 my $name = shift;
680  
681 0 ▶ return if not $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
682  
683 0 return index ( $name, q{::} ) >= 0;
684 }
685  
686 #-----------------------------------------------------------------------------
687  
688 36 ▶sub precedence_of {
Subroutine precedence_of: called CC=3 SCAR=11.1
Pod documented
689 36 my $elem = shift;
690 36 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 36 36
691 36 ▶ return $PRECEDENCE_OF{ ref $elem ? "$elem" : $elem };
Branch: 1 branch
BranchTrueFalseTotal
ref $elem ? : 4 32 36
692 }
693  
694 #-----------------------------------------------------------------------------
695  
696 20 ▶sub is_hash_key {
Subroutine is_hash_key: called CC=9 SCAR=23.2
Pod documented
697 20 my $elem = shift;
698 20 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 20 20
699  
700 #If followed by an argument list, then its a function call, not a literal
701 20 ▶ return if _is_followed_by_parens($elem);
Branch: 1 branch
BranchTrueFalseTotal
if _is_followed_by_parens($elem) 8 12 20
702  
703 #Check curly-brace style: $hash{foo} = bar;
704 12 my $parent = $elem->parent();
705 12 ▶ return if !$parent;
Branch: 1 branch
BranchTrueFalseTotal
unless $parent 0 12 12
706 12 my $grandparent = $parent->parent();
707 12 ▶ return if !$grandparent;
Branch: 1 branch
BranchTrueFalseTotal
unless $grandparent 0 12 12
708 12 ▶ return 1 if $grandparent->isa('PPI::Structure::Subscript');
Branch: 1 branch
BranchTrueFalseTotal
if $grandparent->isa("PPI::Structure::Subscript") 2 10 12
709  
710  
711 #Check declarative style: %hash = (foo => bar);
712 10 my $sib = $elem->snext_sibling();
713 10 ▶ return if !$sib;
Branch: 1 branch
BranchTrueFalseTotal
unless $sib 0 10 10
714 10 ▶ return 1 if $sib->isa('PPI::Token::Operator') && $sib eq '=>';
Branch: 1 branch
BranchTrueFalseTotal
if $sib->isa("PPI::Token::Operator") and $sib eq "=>" 0 10 10
Condition33%1/3
$sib->isa("PPI::Token::Operator") and $sib eq "=>"
!ll&&!rl&&r
1000
MC/DC0%0/2
$sib->isa("PPI::Token::Operator") and $sib eq "=>"
$sib->isa("PPI::Token::Operator") $sib eq "=>"
Truth table33%1/3
A and B
A= $sib->isa("PPI::Token::Operator")B= $sib eq "=>"
ABresult
0X0
100
111
715  
716 10 return;
717 }
718  
719 #-----------------------------------------------------------------------------
720  
721 20 ▶sub _is_followed_by_parens {
Subroutine _is_followed_by_parens: called CC=3 SCAR=11.0
722 20 my $elem = shift;
723 20 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 20 20
724  
725 20 ▶ my $sibling = $elem->snext_sibling() || return;
Condition100%2/2
$elem->snext_sibling || (return)
l!l
182
MC/DC100%1/1
$elem->snext_sibling || (return)
$elem->snext_sibling
Truth table100%2/2
A
A= $elem->snext_sibling
Aresult
11
00
726 18 return $sibling->isa('PPI::Structure::List');
727 }
728  
729 #-----------------------------------------------------------------------------
730  
731 15 ▶sub is_included_module_name {
Subroutine is_included_module_name: called CC=4 SCAR=15.2
Pod documented
732 15 my $elem = shift;
733 15 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 15 15
734 15 my $stmnt = $elem->statement();
735 15 ▶ return if !$stmnt;
Branch: 1 branch
BranchTrueFalseTotal
unless $stmnt 0 15 15
736 15 ▶ return if !$stmnt->isa('PPI::Statement::Include');
Branch: 1 branch
BranchTrueFalseTotal
unless $stmnt->isa("PPI::Statement::Include") 15 0 15
737 0 return $stmnt->schild(1) == $elem;
738 }
739  
740 #-----------------------------------------------------------------------------
741  
742 352 ▶sub is_integer {
Subroutine is_integer: called CC=2 SCAR=7.1
Pod documented
743 352 my ($value) = @_;
744 352 ▶ return 0 if not defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 352 352
745  
746 352 return $value =~ m{ \A [+-]? \d+ \z }xms;
747 }
748  
749 #-----------------------------------------------------------------------------
750  
751 14 ▶sub is_label_pointer {
Subroutine is_label_pointer: called CC=5 SCAR=16.4
Pod documented
752 14 my $elem = shift;
753 14 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 14 14
754  
755 14 my $statement = $elem->statement();
756 14 ▶ return if !$statement;
Branch: 1 branch
BranchTrueFalseTotal
unless $statement 0 14 14
757  
758 14 my $psib = $elem->sprevious_sibling();
759 14 ▶ return if !$psib;
Branch: 1 branch
BranchTrueFalseTotal
unless $psib 12 2 14
760  
761 2 ▶ return $statement->isa('PPI::Statement::Break')
Condition66%2/3
$statement->isa('PPI::Statement::Break') && $psib =~ /(?:redo|goto|next|last)/mosx
!ll&&!rl&&r
110
MC/DC0%0/2
$statement->isa('PPI::Statement::Break') && $psib =~ /(?:redo|goto|next|last)/mosx
$statement->isa('PPI::Statement::Break') $psib =~ /(?:redo|goto|next|last)/mosx
Truth table66%2/3
A && B
A= $statement->isa('PPI::Statement::Break')B= $psib =~ /(?:redo|goto|next|last)/mosx
ABresult
0X0
100
111
762 && $psib =~ m/(?:redo|goto|next|last)/xmso;
763 }
764  
765 #-----------------------------------------------------------------------------
766  
767 15 ▶sub is_method_call {
Subroutine is_method_call: called CC=2 SCAR=7.1
Pod documented
768 15 my $elem = shift;
769 15 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 15 15
770  
771 15 return _is_dereference_operator( $elem->sprevious_sibling() );
772 }
773  
774 #-----------------------------------------------------------------------------
775  
776 15 ▶sub is_class_name {
Subroutine is_class_name: called CC=3 SCAR=12.5
Pod documented
777 15 my $elem = shift;
778 15 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 15 15
779  
780 15 ▶ return _is_dereference_operator( $elem->snext_sibling() )
Condition33%1/3
_is_dereference_operator($elem->snext_sibling) && !_is_dereference_operator($elem->sprevious_sibling)
!ll&&!rl&&r
1500
MC/DC0%0/2
_is_dereference_operator($elem->snext_sibling) && !_is_dereference_operator($elem->sprevious_sibling)
_is_dereference_operator($elem->snext_sibling) !_is_dereference_operator($elem->sprevious_sibling)
Truth table33%1/3
A && not(B)
A= _is_dereference_operator($elem->snext_sibling)B= !_is_dereference_operator($elem->sprevious_sibling)
ABresult
0X0
100
111
781 && !_is_dereference_operator( $elem->sprevious_sibling() );
782 }
783  
784 #-----------------------------------------------------------------------------
785  
786 30 ▶sub _is_dereference_operator {
Subroutine _is_dereference_operator: called CC=3 SCAR=11.0
787 30 my $elem = shift;
788 30 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 12 18 30
789  
790 18 ▶ return $elem->isa('PPI::Token::Operator') && $elem eq q{->};
Condition66%2/3
$elem->isa('PPI::Token::Operator') && $elem eq '->'
!ll&&!rl&&r
1620
MC/DC0%0/2
$elem->isa('PPI::Token::Operator') && $elem eq '->'
$elem->isa('PPI::Token::Operator') $elem eq '->'
Truth table66%2/3
A && B
A= $elem->isa('PPI::Token::Operator')B= $elem eq '->'
ABresult
0X0
100
111
791 }
792  
793 #-----------------------------------------------------------------------------
794  
795 15 ▶sub is_package_declaration {
Subroutine is_package_declaration: called CC=4 SCAR=15.2
Pod documented
796 15 my $elem = shift;
797 15 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 15 15
798 15 my $stmnt = $elem->statement();
799 15 ▶ return if !$stmnt;
Branch: 1 branch
BranchTrueFalseTotal
unless $stmnt 0 15 15
800 15 ▶ return if !$stmnt->isa('PPI::Statement::Package');
Branch: 1 branch
BranchTrueFalseTotal
unless $stmnt->isa("PPI::Statement::Package") 15 0 15
801 0 return $stmnt->schild(1) == $elem;
802 }
803  
804 #-----------------------------------------------------------------------------
805  
806 17 ▶sub is_subroutine_name {
Subroutine is_subroutine_name: called CC=5 SCAR=16.4
Pod documented
807 17 my $elem = shift;
808 17 ▶ return if !$elem;
Branch: 1 branch
BranchTrueFalseTotal
unless $elem 0 17 17
809 17 my $sib = $elem->sprevious_sibling();
810 17 ▶ return if !$sib;
Branch: 1 branch
BranchTrueFalseTotal
unless $sib 12 5 17
811 5 my $stmnt = $elem->statement();
812 5 ▶ return if !$stmnt;
Branch: 1 branch
BranchTrueFalseTotal
unless $stmnt 0 5 5
813 5 ▶ return $stmnt->isa('PPI::Statement::Sub') && $sib eq 'sub';
Condition66%2/3
$stmnt->isa('PPI::Statement::Sub') && $sib eq 'sub'
!ll&&!rl&&r
302
MC/DC50%1/2
$stmnt->isa('PPI::Statement::Sub') && $sib eq 'sub'
$stmnt->isa('PPI::Statement::Sub') $sib eq 'sub'
Truth table66%2/3
A && B
A= $stmnt->isa('PPI::Statement::Sub')B= $sib eq 'sub'
ABresult
0X0
100
111
814 }
815  
816 #-----------------------------------------------------------------------------
817  
818 16 ▶sub is_function_call {
Subroutine is_function_call: called CC=11 SCAR=25.7
Pod documented
819 16 ▶ my $elem = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $elem = shift() or return 16 0 16
820  
821 16 ▶ return if is_perl_bareword($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_perl_bareword($elem) 1 15 16
822 15 ▶ return if is_perl_filehandle($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_perl_filehandle($elem) 0 15 15
823 15 ▶ return if is_package_declaration($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_package_declaration($elem) 0 15 15
824 15 ▶ return if is_included_module_name($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_included_module_name($elem) 0 15 15
825 15 ▶ return if is_method_call($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_method_call($elem) 0 15 15
826 15 ▶ return if is_class_name($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_class_name($elem) 0 15 15
827 15 ▶ return if is_subroutine_name($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_subroutine_name($elem) 1 14 15
828 14 ▶ return if is_label_pointer($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_label_pointer($elem) 0 14 14
829 14 ▶ return if is_hash_key($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_hash_key($elem) 0 14 14
830  
831 14 return 1;
832 }
833  
834 #-----------------------------------------------------------------------------
835  
836 8 ▶sub is_script {
Subroutine is_script: called CC=5 SCAR=16.5
Pod documented
837 8 my $doc = shift;
838  
839 8 warnings::warnif(
840 'deprecated',
841 'Perl::ToPerl6::Utils::is_script($doc) deprecated, use $doc->is_program() instead.',
842 );
843  
844 8 ▶ return $doc->is_program()
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($doc) and $doc->isa("Perl::ToPerl6::Document") 0 8 8
Condition33%1/3
builtin::blessed($doc) and $doc->isa("Perl::ToPerl6::Document")
!ll&&!rl&&r
080
MC/DC0%0/2
builtin::blessed($doc) and $doc->isa("Perl::ToPerl6::Document")
builtin::blessed($doc) $doc->isa("Perl::ToPerl6::Document")
Truth table33%1/3
A and B
A= builtin::blessed($doc)B= $doc->isa("Perl::ToPerl6::Document")
ABresult
0X0
100
111
845 if blessed($doc) && $doc->isa('Perl::ToPerl6::Document');
846  
847 8 ▶ return 1 if shebang_line($doc);
Branch: 1 branch
BranchTrueFalseTotal
if shebang_line($doc) 5 3 8
848 3 ▶ return 1 if _is_PL_file($doc);
Branch: 1 branch
BranchTrueFalseTotal
if _is_PL_file($doc) 1 2 3
849 2 return 0;
850 }
851  
852 #-----------------------------------------------------------------------------
853  
854 3 ▶sub _is_PL_file {
Subroutine _is_PL_file: called CC=4 SCAR=14.6
855 3 my ($doc) = @_;
856 3 ▶ return if not $doc->can('filename');
Branch: 1 branch
BranchTrueFalseTotal
unless $doc->can("filename") 0 3 3
857 3 ▶ my $filename = $doc->filename() || return;
Condition100%2/2
$doc->filename || (return)
l!l
12
MC/DC100%1/1
$doc->filename || (return)
$doc->filename
Truth table100%2/2
A
A= $doc->filename
Aresult
11
00
858 1 ▶ return 1 if $filename =~ m/[.] PL \z/xms;
Branch: 1 branch
BranchTrueFalseTotal
if $filename =~ /[.] PL \z/msx 1 0 1
859 0 return 0;
860 }
861  
862 #-----------------------------------------------------------------------------
863  
864 0 ▶sub is_in_void_context {
Subroutine is_in_void_context: not called CC=11 SCAR=48.8
Pod documented
865 0 my ($token) = @_;
866  
867 # If part of a collective, can't be void.
868 0 ▶ return if $token->sprevious_sibling();
Branch: 1 branch
BranchTrueFalseTotal
if $token->sprevious_sibling 0 0 0
869  
870 0 my $parent = $token->statement()->parent();
871 0 ▶ if ($parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent) 0 0 0
872 0 ▶ return if $parent->isa('PPI::Structure::List');
Branch: 1 branch
BranchTrueFalseTotal
if $parent->isa("PPI::Structure::List") 0 0 0
873 0 ▶ return if $parent->isa('PPI::Structure::For');
Branch: 1 branch
BranchTrueFalseTotal
if $parent->isa("PPI::Structure::For") 0 0 0
874 0 ▶ return if $parent->isa('PPI::Structure::Condition');
Branch: 1 branch
BranchTrueFalseTotal
if $parent->isa("PPI::Structure::Condition") 0 0 0
875 0 ▶ return if $parent->isa('PPI::Structure::Constructor');
Branch: 1 branch
BranchTrueFalseTotal
if $parent->isa("PPI::Structure::Constructor") 0 0 0
876 0 ▶ return if $parent->isa('PPI::Structure::Subscript');
Branch: 1 branch
BranchTrueFalseTotal
if $parent->isa("PPI::Structure::Subscript") 0 0 0
877  
878 0 my $grand_parent = $parent->parent();
879 0 ▶ if ($grand_parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($grand_parent) 0 0 0
880 return if
881 0 ▶ $parent->isa('PPI::Structure::Block')
Branch: 1 branch
BranchTrueFalseTotal
if $parent->isa("PPI::Structure::Block") and not $grand_parent->isa("PPI::Statement::Compound") 0 0 0
Condition0%0/3
$parent->isa("PPI::Structure::Block") and not $grand_parent->isa("PPI::Statement::Compound")
!ll&&!rl&&r
000
MC/DC0%0/2
$parent->isa("PPI::Structure::Block") and not $grand_parent->isa("PPI::Statement::Compound")
$parent->isa("PPI::Structure::Block") not $grand_parent->isa("PPI::Statement::Compound")
Truth table0%0/3
A and not(B)
A= $parent->isa("PPI::Structure::Block")B= not $grand_parent->isa("PPI::Statement::Compound")
ABresult
0X0
100
111
882 and not $grand_parent->isa('PPI::Statement::Compound');
883 }
884 }
885  
886 0 return $TRUE;
887 }
888  
889 #-----------------------------------------------------------------------------
890  
891 2719 ▶sub transformer_long_name {
Subroutine transformer_long_name: called CC=2 SCAR=6.9
Pod documented
892 2719 my ( $transformer_name ) = @_;
893 2719 ▶ if ( $transformer_name !~ m{ \A $TRANSFORMER_NAMESPACE }xms ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($transformer_name =~ / \A $Perl::ToPerl6::Utils::TRANSFORMER_NAMESPACE /msx) 70 2649 2719
894 70 $transformer_name = $TRANSFORMER_NAMESPACE . q{::} . $transformer_name;
895 }
896 2719 return $transformer_name;
897 }
898  
899 #-----------------------------------------------------------------------------
900  
901 12868 ▶sub transformer_short_name {
Subroutine transformer_short_name: called CC=1 SCAR=0.0
Pod documented
902 12868 my ( $transformer_name ) = @_;
903 12868 $transformer_name =~ s{\A $TRANSFORMER_NAMESPACE ::}{}xms;
904 12868 return $transformer_name;
905 }
906  
907 #-----------------------------------------------------------------------------
908  
909 7 ▶sub first_arg {
Subroutine first_arg: called CC=5 SCAR=16.2
Pod documented
910 7 my $elem = shift;
911 7 my $sib = $elem->snext_sibling();
912 7 ▶ return if !$sib;
Branch: 1 branch
BranchTrueFalseTotal
unless $sib 0 7 7
913  
914 7 ▶ if ( $sib->isa('PPI::Structure::List') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sib->isa("PPI::Structure::List")) 2 5 7
915  
916 2 my $expr = $sib->schild(0);
917 2 ▶ return if !$expr;
Branch: 1 branch
BranchTrueFalseTotal
unless $expr 1 1 2
918 1 ▶ return $expr->isa('PPI::Statement') ? $expr->schild(0) : $expr;
Branch: 1 branch
BranchTrueFalseTotal
$expr->isa('PPI::Statement') ? : 1 0 1
919 }
920  
921 5 return $sib;
922 }
923  
924 #-----------------------------------------------------------------------------
925  
926 11 ▶sub parse_arg_list {
Subroutine parse_arg_list: called CC=11 SCAR=24.9
Pod documented
927 11 my $elem = shift;
928 11 my $sib = $elem->snext_sibling();
929 11 ▶ return if !$sib;
Branch: 1 branch
BranchTrueFalseTotal
unless $sib 0 11 11
930  
931 11 ▶ if ( $sib->isa('PPI::Structure::List') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sib->isa('PPI::Structure::List')) { } 3 8 11
932  
933 #Pull siblings from list
934 3 my @list_contents = $sib->schildren();
935 3 ▶ return if not @list_contents;
Branch: 1 branch
BranchTrueFalseTotal
unless @list_contents 0 3 3
936  
937 3 my @list_expressions;
938 3 foreach my $item (@list_contents) {
939 3 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (is_ppi_expression_or_generic_statement($item)) { } 3 0 3
940 is_ppi_expression_or_generic_statement($item)
941 ) {
942 3 push
943 @list_expressions,
944 split_nodes_on_comma( $item->schildren() );
945 }
946 else {
947 0 push @list_expressions, $item;
948 }
949 }
950  
951 3 return @list_expressions;
952 }
953 else {
954  
955 #Gather up remaining nodes in the statement
956 8 my $iter = $elem;
957 8 my @arg_list = ();
958  
959 8 ▶ while ($iter = $iter->snext_sibling() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iter = $iter->snext_sibling) 19 0 19
960 19 ▶ last if $iter->isa('PPI::Token::Structure') and $iter eq $SCOLON;
Branch: 1 branch
BranchTrueFalseTotal
if $iter->isa("PPI::Token::Structure") and $iter eq $Perl::ToPerl6::Utils::SCOLON 8 11 19
Condition66%2/3
$iter->isa("PPI::Token::Structure") and $iter eq $Perl::ToPerl6::Utils::SCOLON
!ll&&!rl&&r
1108
MC/DC50%1/2
$iter->isa("PPI::Token::Structure") and $iter eq $Perl::ToPerl6::Utils::SCOLON
$iter->isa("PPI::Token::Structure") $iter eq $Perl::ToPerl6::Utils::SCOLON
Truth table66%2/3
A and B
A= $iter->isa("PPI::Token::Structure")B= $iter eq $Perl::ToPerl6::Utils::SCOLON
ABresult
0X0
100
111
961 11 ▶ last if $iter->isa('PPI::Token::Operator')
Branch: 1 branch
BranchTrueFalseTotal
if $iter->isa("PPI::Token::Operator") and $MIN_PRECEDENCE_TO_TERMINATE_PARENLESS_ARG_LIST <= precedence_of($iter) 0 11 11
Condition66%2/3
$iter->isa("PPI::Token::Operator") and $MIN_PRECEDENCE_TO_TERMINATE_PARENLESS_ARG_LIST <= precedence_of($iter)
!ll&&!rl&&r
920
MC/DC0%0/2
$iter->isa("PPI::Token::Operator") and $MIN_PRECEDENCE_TO_TERMINATE_PARENLESS_ARG_LIST <= precedence_of($iter)
$iter->isa("PPI::Token::Operator") $MIN_PRECEDENCE_TO_TERMINATE_PARENLESS_ARG_LIST <= precedence_of($iter)
Truth table66%2/3
A and B
A= $iter->isa("PPI::Token::Operator")B= $MIN_PRECEDENCE_TO_TERMINATE_PARENLESS_ARG_LIST <= precedence_of($iter)
ABresult
0X0
100
111
962 and $MIN_PRECEDENCE_TO_TERMINATE_PARENLESS_ARG_LIST <=
963 precedence_of( $iter );
964 11 push @arg_list, $iter;
965 }
966 8 return split_nodes_on_comma( @arg_list );
967 }
968 }
969  
970 #---------------------------------
971  
972 11 ▶sub split_nodes_on_comma {
Subroutine split_nodes_on_comma: called CC=8 SCAR=20.9
Pod documented
973 11 my @nodes = @_;
974  
975 11 my $i = 0;
976 11 my @node_stacks;
977 11 for my $node (@nodes) {
978 26 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($node->isa('PPI::Token::Operator') and $node eq $Perl::ToPerl6::Utils::COMMA || $node eq $Perl::ToPerl6::Utils::FATCOMMA) { } 8 18 26
elsif ($node->isa('PPI::Token::QuoteLike::Words')) { } 7 11 18
Condition66%4/6
$node->isa("PPI::Token::Operator") and $node eq $Perl::ToPerl6::Utils::COMMA || $node eq $Perl::ToPerl6::Utils::FATCOMMA
!ll&&!rl&&r
1808
$node eq $Perl::ToPerl6::Utils::COMMA or $node eq $Perl::ToPerl6::Utils::FATCOMMA
l!l&&r!l&&!r
620
MC/DC33%1/3
$node->isa("PPI::Token::Operator") and $node eq $Perl::ToPerl6::Utils::COMMA || $node eq $Perl::ToPerl6::Utils::FATCOMMA
$node->isa("PPI::Token::Operator") $node eq $Perl::ToPerl6::Utils::COMMA $node eq $Perl::ToPerl6::Utils::FATCOMMA
Truth table75%3/4
A and B or C
A= $node->isa("PPI::Token::Operator")B= $node eq $Perl::ToPerl6::Utils::COMMAC= $node eq $Perl::ToPerl6::Utils::FATCOMMA
ABCresult
0XX0
1000
11X1
1011
979 $node->isa('PPI::Token::Operator')
980 and ($node eq $COMMA or $node eq $FATCOMMA)
981 ) {
982 8 ▶ if (@node_stacks) {
Branch: 1 branch
BranchTrueFalseTotal
if (@node_stacks) 8 0 8
983 8 $i++; #Move forward to next 'node stack'
984 }
985 8 next;
986 } elsif ( $node->isa('PPI::Token::QuoteLike::Words' )) {
987 7 my $section = $node->{sections}->[0];
988 7 my @words = words_from_string(substr $node->content, $section->{position}, $section->{size});
989 7 my $loc = $node->location;
990 7 for my $word (@words) {
991 10 my $token = PPI::Token::Quote::Single->new(q{'} . $word . q{'});
992 10 $token->{_location} = $loc;
993 10 push @{ $node_stacks[$i++] }, $token;
994 }
995 7 next;
996 }
997 11 push @{ $node_stacks[$i] }, $node;
998 }
999 11 return @node_stacks;
1000 }
1001  
1002 #-----------------------------------------------------------------------------
1003  
1004 # XXX: You must keep the regular expressions in extras/perlmogrify.el in sync
1005 # if you change these.
1006 30 Readonly::Hash my %FORMAT_OF => (
1007 1 => "%f:%l:%c:%m\n",
1008 2 => "%f: (%l:%c) %m\n",
1009 3 => "%m at %f line %l\n",
1010 4 => "%m at line %l, column %c. %e. (Necessity: %s)\n",
1011 5 => "%f: %m at line %l, column %c. %e. (Necessity: %s)\n",
1012 6 => "%m at line %l, near '%r'. (Necessity: %s)\n",
1013 7 => "%f: %m at line %l near '%r'. (Necessity: %s)\n",
1014 8 => "[%p] %m at line %l, column %c. (Necessity: %s)\n",
1015 9 => "[%p] %m at line %l, near '%r'. (Necessity: %s)\n",
1016 10 => "%m at line %l, column %c.\n %p (Necessity: %s)\n%d\n",
1017 11 => "%m at line %l, near '%r'.\n %p (Necessity: %s)\n%d\n",
1018 );
1019  
1020 30 Readonly::Scalar our $DEFAULT_VERBOSITY => 4;
1021 30 Readonly::Scalar our $DEFAULT_VERBOSITY_WITH_FILE_NAME => 5;
1022 30 Readonly::Scalar my $DEFAULT_FORMAT => $FORMAT_OF{$DEFAULT_VERBOSITY};
1023  
1024 71 ▶sub is_valid_numeric_verbosity {
Subroutine is_valid_numeric_verbosity: called CC=1 SCAR=0.0
Pod documented
1025 71 my ($verbosity) = @_;
1026  
1027 71 return exists $FORMAT_OF{$verbosity};
1028 }
1029  
1030 19 ▶sub verbosity_to_format {
Subroutine verbosity_to_format: called CC=4 SCAR=13.9
Pod documented
1031 19 my ($verbosity) = @_;
1032 19 ▶ return $DEFAULT_FORMAT if not defined $verbosity;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $verbosity 1 18 19
1033 18 ▶ return $FORMAT_OF{abs int $verbosity} || $DEFAULT_FORMAT if is_integer($verbosity);
Branch: 1 branch
BranchTrueFalseTotal
if is_integer($verbosity) 2 16 18
Condition66%2/3
$FORMAT_OF{abs int $verbosity} || $DEFAULT_FORMAT
l!l&&r!l&&!r
110
MC/DC0%0/2
$FORMAT_OF{abs int $verbosity} || $DEFAULT_FORMAT
$FORMAT_OF{abs int $verbosity} $DEFAULT_FORMAT
Truth table66%2/3
A || B
A= $FORMAT_OF{abs int $verbosity}B= $DEFAULT_FORMAT
ABresult
1X1
011
000
1034 16 return interpolate( $verbosity ); #Otherwise, treat as a format spec
1035 }
1036  
1037 #-----------------------------------------------------------------------------
1038  
1039 30 Readonly::Hash my %NECESSITY_NUMBER_OF => (
1040 gentle => 5,
1041 stern => 4,
1042 harsh => 3,
1043 cruel => 2,
1044 brutal => 1,
1045 );
1046  
1047 Readonly::Array our @NECESSITY_NAMES => #This is exported!
1048 sort
1049 30 { $NECESSITY_NUMBER_OF{$a} <=> $NECESSITY_NUMBER_OF{$b} }
1050 keys %NECESSITY_NUMBER_OF;
1051  
1052 50 ▶sub necessity_to_number {
Subroutine necessity_to_number: called CC=3 SCAR=11.0
Pod documented
1053 50 my ($necessity) = @_;
1054 50 ▶ return _normalize_necessity( $necessity ) if is_integer( $necessity );
Branch: 1 branch
BranchTrueFalseTotal
if is_integer($necessity) 44 6 50
1055 6 my $necessity_number = $NECESSITY_NUMBER_OF{lc $necessity};
1056  
1057 6 ▶ if ( not defined $necessity_number ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $necessity_number) 1 5 6
1058 1 throw_generic qq{Invalid necessity: "$necessity"};
1059 }
1060  
1061 5 return $necessity_number;
1062 }
1063  
1064 44 ▶sub _normalize_necessity {
Subroutine _normalize_necessity: called CC=4 SCAR=14.9
1065 44 ▶ my $s = shift || return $NECESSITY_HIGHEST;
Condition50%1/2
shift() || (return $Perl::ToPerl6::Utils::NECESSITY_HIGHEST)
l!l
440
MC/DC0%0/1
shift() || (return $Perl::ToPerl6::Utils::NECESSITY_HIGHEST)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1066 44 ▶ $s = $s > $NECESSITY_HIGHEST ? $NECESSITY_HIGHEST : $s;
Branch: 1 branch
BranchTrueFalseTotal
$s > $Perl::ToPerl6::Utils::NECESSITY_HIGHEST ? : 0 44 44
1067 44 ▶ $s = $s < $NECESSITY_LOWEST ? $NECESSITY_LOWEST : $s;
Branch: 1 branch
BranchTrueFalseTotal
$s < $Perl::ToPerl6::Utils::NECESSITY_LOWEST ? : 0 44 44
1068 44 return $s;
1069 }
1070  
1071 #-----------------------------------------------------------------------------
1072  
1073 30 Readonly::Array my @SKIP_DIR => qw( CVS RCS .svn _darcs {arch} .bzr .cdv .git .hg .pc _build blib );
1074 30 Readonly::Hash my %SKIP_DIR => hashify( @SKIP_DIR );
1075  
1076 1 ▶sub all_perl_files {
Subroutine all_perl_files: called CC=7 SCAR=19.5
Pod documented
1077  
1078 # Recursively searches a list of directories and returns the paths
1079 # to files that seem to be Perl source code. This subroutine was
1080 # poached from Test::Perl::ToPerl6.
1081  
1082 1 my @queue = @_;
1083 1 my @code_files = ();
1084  
1085 1 ▶ while (@queue) {
Branch: 1 branch
BranchTrueFalseTotal
if (@queue) 56 1 57
1086 56 my $file = shift @queue;
1087 56 ▶ if ( -d $file ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $file) 18 38 56
1088 18 ▶ opendir my ($dh), $file or next;
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $file or next 18 0 18
1089 18 my @newfiles = sort readdir $dh;
1090 18 closedir $dh;
1091  
1092 18 @newfiles = File::Spec->no_upwards(@newfiles);
1093 18 @newfiles = grep { not $SKIP_DIR{$_} } @newfiles;
1094 18 push @queue, map { File::Spec->catfile($file, $_) } @newfiles;
1095 }
1096  
1097 56 ▶ if ( (-f $file) && ! _is_backup($file) && _is_perl($file) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $file and not _is_backup($file) and _is_perl($file)) 38 18 56
Condition66%4/6
-f $file and not _is_backup($file) and _is_perl($file)
!ll&&!rl&&r
18038
-f $file and not _is_backup($file)
!ll&&!rl&&r
18038
MC/DC33%1/3
-f $file and not _is_backup($file) and _is_perl($file)
-f $file not _is_backup($file) _is_perl($file)
Truth table50%2/4
A and not(B) and C
A= -f $fileB= not _is_backup($file)C= _is_perl($file)
ABCresult
0XX0
10X0
1100
1111
1098 38 push @code_files, $file;
1099 }
1100 }
1101 1 return @code_files;
1102 }
1103  
1104  
1105 #-----------------------------------------------------------------------------
1106 # Decide if it's some sort of backup file
1107  
1108 45 ▶sub _is_backup {
Subroutine _is_backup: called CC=5 SCAR=16.1
1109 45 my ($file) = @_;
1110 45 ▶ return 1 if $file =~ m{ [.] swp \z}xms;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ / [.] swp \z/msx 1 44 45
1111 44 ▶ return 1 if $file =~ m{ [.] bak \z}xms;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ / [.] bak \z/msx 1 43 44
1112 43 ▶ return 1 if $file =~ m{ ~ \z}xms;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ / ~ \z/msx 1 42 43
1113 42 ▶ return 1 if $file =~ m{ \A [#] .+ [#] \z}xms;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ / \A [#] .+ [#] \z/msx 1 41 42
1114 41 return;
1115 }
1116  
1117 #-----------------------------------------------------------------------------
1118 # Returns true if the argument ends with a perl-ish file
1119 # extension, or if it has a shebang-line containing 'perl' This
1120 # subroutine was also poached from Test::Perl::ToPerl6
1121  
1122 55 ▶sub _is_perl {
Subroutine _is_perl: called CC=8 SCAR=20.8
1123 55 my ($file) = @_;
1124  
1125 #Check filename extensions
1126 55 ▶ return 1 if $file =~ m{ [.] PL \z}xms;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ / [.] PL \z/msx 1 54 55
1127 54 ▶ return 1 if $file =~ m{ [.] p[lm] \z}xms;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ / [.] p[lm] \z/msx 40 14 54
1128 14 ▶ return 1 if $file =~ m{ [.] t \z}xms;
Branch: 1 branch
BranchTrueFalseTotal
if $file =~ / [.] t \z/msx 1 13 14
1129  
1130 #Check for shebang
1131 13 ▶ open my $fh, '<', $file or return;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $file or return 9 4 13
1132 9 my $first = <$fh>;
1133 9 ▶ close $fh or throw_generic "unable to close $file: $OS_ERROR";
Branch: 1 branch
BranchTrueFalseTotal
close $fh or throw_generic("unable to close ${file}: $Perl::ToPerl6::Utils::OS_ERROR") 9 0 9
1134  
1135 9 ▶ return 1 if defined $first && ( $first =~ m{ \A [#]!.*perl }xms );
Branch: 1 branch
BranchTrueFalseTotal
if defined $first and $first =~ / \A [#]!.*perl /msx 6 3 9
Condition66%2/3
defined $first and $first =~ / \A [#]!.*perl /msx
!ll&&!rl&&r
036
MC/DC50%1/2
defined $first and $first =~ / \A [#]!.*perl /msx
defined $first $first =~ / \A [#]!.*perl /msx
Truth table66%2/3
A and B
A= defined $firstB= $first =~ / \A [#]!.*perl /msx
ABresult
0X0
100
111
1136 3 return;
1137 }
1138  
1139 #-----------------------------------------------------------------------------
1140  
1141 68 ▶sub shebang_line {
Subroutine shebang_line: called CC=7 SCAR=19.8
Pod documented
1142 68 my $doc = shift;
1143 68 my $first_element = $doc->first_element();
1144 68 ▶ return if not $first_element;
Branch: 1 branch
BranchTrueFalseTotal
unless $first_element 0 68 68
1145 68 ▶ return if not $first_element->isa('PPI::Token::Comment');
Branch: 1 branch
BranchTrueFalseTotal
unless $first_element->isa("PPI::Token::Comment") 52 16 68
1146 16 my $location = $first_element->location();
1147 16 ▶ return if !$location;
Branch: 1 branch
BranchTrueFalseTotal
unless $location 0 16 16
1148 # The shebang must be the first two characters in the file, according to
1149 # http://en.wikipedia.org/wiki/Shebang_(Unix)
1150 16 ▶ return if $location->[0] != 1; # line number
Branch: 1 branch
BranchTrueFalseTotal
if $location->[0] != 1 0 16 16
1151 16 ▶ return if $location->[1] != 1; # column number
Branch: 1 branch
BranchTrueFalseTotal
if $location->[1] != 1 0 16 16
1152 16 my $shebang = $first_element->content;
1153 16 ▶ return if $shebang !~ m{ \A [#]! }xms;
Branch: 1 branch
BranchTrueFalseTotal
unless $shebang =~ / \A [#]! /msx 2 14 16
1154 14 return $shebang;
1155 }
1156  
1157 #-----------------------------------------------------------------------------
1158  
1159 857 ▶sub words_from_string {
Subroutine words_from_string: called CC=1 SCAR=0.0
Pod documented
1160 857 my $str = shift;
1161  
1162 857 return split q{ }, $str; # This must be a literal space, not $SPACE
1163 }
1164  
1165 #-----------------------------------------------------------------------------
1166  
1167 30 Readonly::Hash my %ASSIGNMENT_OPERATORS => hashify( qw( = **= += -= .= *= /= %= x= &= |= ^= <<= >>= &&= ||= //= ) );
1168  
1169 29 ▶sub is_assignment_operator {
Subroutine is_assignment_operator: called CC=1 SCAR=0.0
Pod documented
1170 29 my $elem = shift;
1171  
1172 29 return $ASSIGNMENT_OPERATORS{ $elem };
1173 }
1174  
1175 #-----------------------------------------------------------------------------
1176  
1177 14 ▶sub is_unchecked_call {
Subroutine is_unchecked_call: called CC=13 SCAR=26.2
Pod documented
1178 14 my $elem = shift;
1179  
1180 14 ▶ return if not is_function_call( $elem );
Branch: 1 branch
BranchTrueFalseTotal
unless is_function_call($elem) 0 14 14
1181  
1182 # check to see if there's an '=' or 'unless' or something before this.
1183 14 ▶ if( my $sib = $elem->sprevious_sibling() ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $sib = $elem->sprevious_sibling) 2 12 14
1184 2 ▶ return if $sib;
Branch: 1 branch
BranchTrueFalseTotal
if $sib 2 0 2
1185 }
1186  
1187  
1188 12 ▶ if( my $statement = $elem->statement() ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $statement = $elem->statement) 12 0 12
1189  
1190 # "open or die" is OK.
1191 # We can't check snext_sibling for 'or' since the next siblings are an
1192 # unknown number of arguments to the system call. Instead, check all of
1193 # the elements to this statement to see if we find 'or' or '||'.
1194  
1195 90 ▶ my $or_operators = sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
1196 90 my (undef, $elem) = @_;
1197 90 ▶ return if not $elem->isa('PPI::Token::Operator');
Branch: 1 branch
BranchTrueFalseTotal
unless $elem->isa("PPI::Token::Operator") 77 13 90
1198 13 ▶ return if $elem ne q{or} && $elem ne q{||};
Branch: 1 branch
BranchTrueFalseTotal
if $elem ne "or" and $elem ne "||" 12 1 13
Condition66%2/3
$elem ne "or" and $elem ne "||"
!ll&&!rl&&r
1012
MC/DC50%1/2
$elem ne "or" and $elem ne "||"
$elem ne "or" $elem ne "||"
Truth table66%2/3
A and B
A= $elem ne "or"B= $elem ne "||"
ABresult
0X0
100
111
1199 1 return 1;
1200 12 };
1201  
1202 12 ▶ return if $statement->find( $or_operators );
Branch: 1 branch
BranchTrueFalseTotal
if $statement->find($or_operators) 1 11 12
1203  
1204  
1205 11 ▶ if( my $parent = $elem->statement()->parent() ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $parent = $elem->statement->parent) 11 0 11
1206  
1207 # Check if we're in an if( open ) {good} else {bad} condition
1208 11 ▶ return if $parent->isa('PPI::Structure::Condition');
Branch: 1 branch
BranchTrueFalseTotal
if $parent->isa("PPI::Structure::Condition") 0 11 11
1209  
1210 # Return val could be captured in data structure and checked later
1211 11 ▶ return if $parent->isa('PPI::Structure::Constructor');
Branch: 1 branch
BranchTrueFalseTotal
if $parent->isa("PPI::Structure::Constructor") 0 11 11
1212  
1213 # "die if not ( open() )" - It's in list context.
1214 11 ▶ if ( $parent->isa('PPI::Structure::List') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->isa("PPI::Structure::List")) 6 5 11
1215 6 ▶ if( my $uncle = $parent->sprevious_sibling() ){
Branch: 1 branch
BranchTrueFalseTotal
if (my $uncle = $parent->sprevious_sibling) 1 5 6
1216 1 ▶ return if $uncle;
Branch: 1 branch
BranchTrueFalseTotal
if $uncle 1 0 1
1217 }
1218 }
1219 }
1220 }
1221  
1222 10 ▶ return if _is_fatal($elem);
Branch: 1 branch
BranchTrueFalseTotal
if _is_fatal($elem) 7 3 10
1223  
1224 # Otherwise, return. this system call is unchecked.
1225 3 return 1;
1226 }
1227  
1228 # Based upon autodie 2.10.
1229 Readonly::Hash my %AUTODIE_PARAMETER_TO_AFFECTED_BUILTINS_MAP => (
1230 # Map builtins to themselves.
1231 (
1232 30 map { $_ => { hashify( $_ ) } }
1233 qw<
1234 accept bind binmode chdir chmod close closedir connect
1235 dbmclose dbmopen exec fcntl fileno flock fork getsockopt ioctl
1236 link listen mkdir msgctl msgget msgrcv msgsnd open opendir
1237 pipe read readlink recv rename rmdir seek semctl semget semop
1238 send setsockopt shmctl shmget shmread shutdown socketpair
1239 symlink sysopen sysread sysseek system syswrite truncate umask
1240 unlink
1241 >
1242 ),
1243  
1244 # Generate these using tools/dump-autodie-tag-contents
1245 ':threads' => { hashify( qw< fork > ) },
1246 ':system' => { hashify( qw< exec system > ) },
1247 ':dbm' => { hashify( qw< dbmclose dbmopen > ) },
1248 ':semaphore' => { hashify( qw< semctl semget semop > ) },
1249 ':shm' => { hashify( qw< shmctl shmget shmread > ) },
1250 ':msg' => { hashify( qw< msgctl msgget msgrcv msgsnd > ) },
1251 ':file' => {
1252 hashify(
1253 qw<
1254 binmode chmod close fcntl fileno flock ioctl open sysopen
1255 truncate
1256 >
1257 )
1258 },
1259 ':filesys' => {
1260 hashify(
1261 qw<
1262 chdir closedir link mkdir opendir readlink rename rmdir
1263 symlink umask unlink
1264 >
1265 )
1266 },
1267 ':ipc' => {
1268 hashify(
1269 qw<
1270 msgctl msgget msgrcv msgsnd pipe semctl semget semop shmctl
1271 shmget shmread
1272 >
1273 )
1274 },
1275 ':socket' => {
1276 hashify(
1277 qw<
1278 accept bind connect getsockopt listen recv send setsockopt
1279 shutdown socketpair
1280 >
1281 )
1282 },
1283 ':io' => {
1284 hashify(
1285 qw<
1286 accept bind binmode chdir chmod close closedir connect
1287 dbmclose dbmopen fcntl fileno flock getsockopt ioctl link
1288 listen mkdir msgctl msgget msgrcv msgsnd open opendir pipe
1289 read readlink recv rename rmdir seek semctl semget semop send
1290 setsockopt shmctl shmget shmread shutdown socketpair symlink
1291 sysopen sysread sysseek syswrite truncate umask unlink
1292 >
1293 )
1294 },
1295 ':default' => {
1296 hashify(
1297 qw<
1298 accept bind binmode chdir chmod close closedir connect
1299 dbmclose dbmopen fcntl fileno flock fork getsockopt ioctl link
1300 listen mkdir msgctl msgget msgrcv msgsnd open opendir pipe
1301 read readlink recv rename rmdir seek semctl semget semop send
1302 setsockopt shmctl shmget shmread shutdown socketpair symlink
1303 sysopen sysread sysseek syswrite truncate umask unlink
1304 >
1305 )
1306 },
1307 ':all' => {
1308 hashify(
1309 qw<
1310 accept bind binmode chdir chmod close closedir connect
1311 dbmclose dbmopen exec fcntl fileno flock fork getsockopt ioctl
1312 link listen mkdir msgctl msgget msgrcv msgsnd open opendir
1313 pipe read readlink recv rename rmdir seek semctl semget semop
1314 send setsockopt shmctl shmget shmread shutdown socketpair
1315 symlink sysopen sysread sysseek system syswrite truncate umask
1316 unlink
1317 >
1318 )
1319 },
1320 );
1321  
1322 10 ▶sub _is_fatal {
Subroutine _is_fatal: called CC=14 SCAR=28.4
1323 10 my ($elem) = @_;
1324  
1325 10 my $top = $elem->top();
1326 10 ▶ return if not $top->isa('PPI::Document');
Branch: 1 branch
BranchTrueFalseTotal
unless $top->isa("PPI::Document") 0 10 10
1327  
1328 10 my $includes = $top->find('PPI::Statement::Include');
1329 10 ▶ return if not $includes;
Branch: 1 branch
BranchTrueFalseTotal
unless $includes 2 8 10
1330  
1331 8 for my $include (@{$includes}) {
1332 8 ▶ next if 'use' ne $include->type();
Branch: 1 branch
BranchTrueFalseTotal
if "use" ne $include->type 0 8 8
1333  
1334 8 ▶ if ('Fatal' eq $include->module()) {
Branch: 3 branches
BranchTrueFalseTotal
if ('Fatal' eq $include->module) { } 2 6 8
elsif ('Fatal::Exception' eq $include->module) { } 2 4 6
elsif ('autodie' eq $include->pragma) { } 4 0 4
1335 2 my @args = parse_arg_list($include->schild(1));
1336 2 foreach my $arg (@args) {
1337 2 ▶ return $TRUE if $arg->[0]->isa('PPI::Token::Quote') && $elem eq $arg->[0]->string();
Branch: 1 branch
BranchTrueFalseTotal
if $arg->[0]->isa("PPI::Token::Quote") and $elem eq $arg->[0]->string 2 0 2
Condition33%1/3
$arg->[0]->isa("PPI::Token::Quote") and $elem eq $arg->[0]->string
!ll&&!rl&&r
002
MC/DC0%0/2
$arg->[0]->isa("PPI::Token::Quote") and $elem eq $arg->[0]->string
$arg->[0]->isa("PPI::Token::Quote") $elem eq $arg->[0]->string
Truth table33%1/3
A and B
A= $arg->[0]->isa("PPI::Token::Quote")B= $elem eq $arg->[0]->string
ABresult
0X0
100
111
1338 }
1339 }
1340 elsif ('Fatal::Exception' eq $include->module()) {
1341 2 my @args = parse_arg_list($include->schild(1));
1342 2 shift @args; # skip exception class name
1343 2 foreach my $arg (@args) {
1344 2 ▶ return $TRUE if $arg->[0]->isa('PPI::Token::Quote') && $elem eq $arg->[0]->string();
Branch: 1 branch
BranchTrueFalseTotal
if $arg->[0]->isa("PPI::Token::Quote") and $elem eq $arg->[0]->string 2 0 2
Condition33%1/3
$arg->[0]->isa("PPI::Token::Quote") and $elem eq $arg->[0]->string
!ll&&!rl&&r
002
MC/DC0%0/2
$arg->[0]->isa("PPI::Token::Quote") and $elem eq $arg->[0]->string
$arg->[0]->isa("PPI::Token::Quote") $elem eq $arg->[0]->string
Truth table33%1/3
A and B
A= $arg->[0]->isa("PPI::Token::Quote")B= $elem eq $arg->[0]->string
ABresult
0X0
100
111
1345 }
1346 }
1347 elsif ('autodie' eq $include->pragma()) {
1348 4 return _is_covered_by_autodie($elem, $include);
1349 }
1350 }
1351  
1352 0 return;
1353 }
1354  
1355 4 ▶sub _is_covered_by_autodie {
Subroutine _is_covered_by_autodie: called CC=9 SCAR=23.5
1356 4 my ($elem, $include) = @_;
1357  
1358 4 my $autodie = $include->schild(1);
1359 4 my @args = parse_arg_list($autodie);
1360 4 my $first_arg = first_arg($autodie);
1361  
1362 # The first argument to any `use` pragma could be a version number.
1363 # If so, then we just discard it. We only want the arguments after it.
1364 0 ▶ if ($first_arg and $first_arg->isa('PPI::Token::Number')){ shift @args };
Branch: 1 branch
BranchTrueFalseTotal
if ($first_arg and $first_arg->isa("PPI::Token::Number")) 0 4 4
Condition33%1/3
$first_arg and $first_arg->isa("PPI::Token::Number")
!ll&&!rl&&r
040
MC/DC0%0/2
$first_arg and $first_arg->isa("PPI::Token::Number")
$first_arg $first_arg->isa("PPI::Token::Number")
Truth table33%1/3
A and B
A= $first_argB= $first_arg->isa("PPI::Token::Number")
ABresult
0X0
100
111
1365  
1366 4 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) { } 3 1 4
1367 3 foreach my $arg (@args) {
1368 my $builtins =
1369 $AUTODIE_PARAMETER_TO_AFFECTED_BUILTINS_MAP{
1370 4 $arg->[0]->string
1371 };
1372  
1373 4 ▶ return $TRUE if $builtins and $builtins->{$elem->content()};
Branch: 1 branch
BranchTrueFalseTotal
if $builtins and $$builtins{$elem->content} 2 2 4
Condition66%2/3
$builtins and $$builtins{$elem->content}
!ll&&!rl&&r
022
MC/DC50%1/2
$builtins and $$builtins{$elem->content}
$builtins $$builtins{$elem->content}
Truth table66%2/3
A and B
A= $builtinsB= $$builtins{$elem->content}
ABresult
0X0
100
111
1374 }
1375 }
1376 else {
1377 my $builtins =
1378 1 $AUTODIE_PARAMETER_TO_AFFECTED_BUILTINS_MAP{':default'};
1379  
1380 1 ▶ return $TRUE if $builtins and $builtins->{$elem->content()};
Branch: 1 branch
BranchTrueFalseTotal
if $builtins and $$builtins{$elem->content} 1 0 1
Condition33%1/3
$builtins and $$builtins{$elem->content}
!ll&&!rl&&r
001
MC/DC0%0/2
$builtins and $$builtins{$elem->content}
$builtins $$builtins{$elem->content}
Truth table33%1/3
A and B
A= $builtinsB= $$builtins{$elem->content}
ABresult
0X0
100
111
1381 }
1382  
1383 1 return;
1384 }
1385  
1386 30 1;
1387  
1388 __END__
« lib/Perl/ToPerl6/Transformer/Variables/RewriteSigils.pm ↑ Summary lib/Perl/ToPerl6/Annotation.pm »