lib/Perl/ToPerl6/Transformer/Packages/RewriteUsages.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 2 / 2 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 13 / 13 Podpod 60.0% 3 / 5 totaltotal 90.6% 58 / 64 CC 4 SCAR 5.8
CC
4
Cov
95%
__ANON__
4.2
applies_to
1.0
BEGIN
1.0
CRAP 1.8
« lib/Perl/ToPerl6/Utils/DataConversion.pm ↑ Summary lib/Perl/ToPerl6/ProfilePrototype.pm »
1 package Perl::ToPerl6::Transformer::Packages::RewriteUsages;
2  
3 17 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 17 ▶use Perl::ToPerl6::Utils qw{ :severities };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 17 ▶use Perl::ToPerl6::Utils::PPI qw{ is_module_name is_pragma };
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 17 ▶use base 'Perl::ToPerl6::Transformer';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #-----------------------------------------------------------------------------
14  
15 17 Readonly::Scalar my $DESC => q{Transform 'use Foo;' to 'use Foo:from<Perl5>;'};
16 17 Readonly::Scalar my $EXPL =>
17 q{Legacy Perl5 classes can be supported using Inline::Perl5 and the :from<Perl5> adverb};
18  
19 #-----------------------------------------------------------------------------
20  
21 17 my %map = (
22 constant => 1
23 );
24  
25 #-----------------------------------------------------------------------------
26  
27 40 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
28 28 ▶sub default_necessity { return $NECESSITY_HIGHEST }
Subroutine default_necessity: called CC=1 SCAR=0.0
Pod documented
29 24 ▶sub default_themes { return qw( core ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
30 5 ▶sub applies_to {
Subroutine applies_to: called CC=1 SCAR=0.1
Pod documented
31 78 ▶ return sub {
Subroutine __ANON__: called CC=4 SCAR=14.3
32 $_[1]->isa('PPI::Statement::Include') and
33 not is_pragma($_[1]->child(2)) and
34 is_module_name($_[1]->child(2)) and
35 78 ▶ not exists $map{$_[1]->child(2)->content}
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Statement::Include") and not is_pragma($_[1]->child(2)) and is_module_name($_[1]->child(2)) and not exists $map{$_[1]->child(2)->content} 1 77 78
Condition66%4/6
$_[1]->isa("PPI::Statement::Include") and not is_pragma($_[1]->child(2)) and is_module_name($_[1]->child(2))
!ll&&!rl&&r
7701
$_[1]->isa("PPI::Statement::Include") and not is_pragma($_[1]->child(2))
!ll&&!rl&&r
7701
MC/DC33%1/3
$_[1]->isa("PPI::Statement::Include") and not is_pragma($_[1]->child(2)) and is_module_name($_[1]->child(2))
$_[1]->isa("PPI::Statement::Include") not is_pragma($_[1]->child(2)) is_module_name($_[1]->child(2))
Truth table50%2/4
A and not(B) and C
A= $_[1]->isa("PPI::Statement::Include")B= not is_pragma($_[1]->child(2))C= is_module_name($_[1]->child(2))
ABCresult
0XX0
10X0
1100
1111
36 }
37 5 }
38  
39 #-----------------------------------------------------------------------------
40  
41 #
42 # 'use Foo;' --> 'use Foo:from<Perl5>;'
43 # 'use Foo qw(a);' --> 'use Foo:from<Perl5> <a>;'
44 #
45 # Although this module only adjusts the 'Foo' bit.
46 #
47 1 ▶sub transform {
Subroutine transform: called CC=1 SCAR=0.0
Pod undocumented
48 1 my ($self, $elem, $doc) = @_;
49  
50 1 my $package_name = $elem->child(2);
51  
52 1 my $old_content = $package_name;
53 1 $old_content .= ':from<Perl5>';
54 1 $package_name->set_content($old_content);
55  
56 1 return $self->transformation( $DESC, $EXPL, $elem );
57 }
58  
59 17 1;
60  
61 #-----------------------------------------------------------------------------
62  
63 __END__
« lib/Perl/ToPerl6/Utils/DataConversion.pm ↑ Summary lib/Perl/ToPerl6/ProfilePrototype.pm »