lib/Perl/ToPerl6/Transformer/Instances/RewriteCreation.pm

filter: Statementstmt 60.4% 29 / 48 Branchbran 12.5% 1 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 92.8% 13 / 14 Podpod 50.0% 3 / 6 totaltotal 56.7% 46 / 81 CC 6 SCAR 21.7
CC
6
Cov
51%
transform
30.0
__ANON__
2.1
applies_to
1.0
CRAP 8.8
« lib/Perl/ToPerl6/Transformer/CompoundStatements/RewriteLoops.pm ↑ Summary lib/Perl/ToPerl6/Exception/Configuration/Option/Transformer/ParameterValue.pm »
1 package Perl::ToPerl6::Transformer::Instances::RewriteCreation;
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{
Subroutine BEGIN: called CC=1 SCAR=0.0
10 is_ppi_token_word
11 dscanf
12 make_ppi_structure_list
13 remove_trailing_whitespace
14 17 };
15  
16 17 ▶use base 'Perl::ToPerl6::Transformer';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 #-----------------------------------------------------------------------------
19  
20 17 Readonly::Scalar my $DESC => q{Transform 'new Foo()' to 'Foo->new()'};
21 17 Readonly::Scalar my $EXPL => q{Transform 'new Foo()' to 'Foo->new()'};
22  
23 #-----------------------------------------------------------------------------
24  
25 #
26 # Run before '->' --> '.' conversion so we don't have to worry.
27 #
28 31 ▶sub run_before { return 'Operators::FormatOperators' }
Subroutine run_before: called CC=1 SCAR=0.0
Pod undocumented
29 38 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
30 27 ▶sub default_necessity { return $NECESSITY_HIGHEST }
Subroutine default_necessity: called CC=1 SCAR=0.0
Pod documented
31 24 ▶sub default_themes { return qw( core ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
32 5 ▶sub applies_to {
Subroutine applies_to: called CC=1 SCAR=0.2
Pod documented
33 78 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
34 78 ▶ dscanf('new %W %L')->(@_) ||
Branch: 1 branch
BranchTrueFalseTotal
dscanf("new %W %L")->(@_) or dscanf("new %W %s")->(@_) 0 78 78
35 dscanf('new %W %s')->(@_)
36 }
37 5 }
38  
39 #-----------------------------------------------------------------------------
40  
41 0 ▶sub transform {
Subroutine transform: not called CC=5 SCAR=34.0
Pod undocumented
42 0 my ($self, $elem, $doc) = @_;
43  
44 0 my $token = $elem->clone;
45 0 ▶ if ( $elem->snext_sibling->snext_sibling->isa('PPI::Token::Quote') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->snext_sibling->snext_sibling->isa("PPI::Token::Quote")) 0 0 0
46 0 my $new_list = make_ppi_structure_list;
47 0 my $new_statement = PPI::Statement->new;
48 0 $new_list->add_element($new_statement);
49 0 $new_statement->add_element(
50 $elem->snext_sibling->snext_sibling->clone
51 );
52  
53 0 ▶ while ( $token and $token->next_sibling ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token and $token->next_sibling) 0 0 0
Condition0%0/3
$token and $token->next_sibling
!ll&&!rl&&r
000
MC/DC0%0/2
$token and $token->next_sibling
$token $token->next_sibling
Truth table0%0/3
A and B
A= $tokenB= $token->next_sibling
ABresult
0X0
100
111
54 0 ▶ last if $token->content eq ',';
Branch: 1 branch
BranchTrueFalseTotal
if $token->content eq "," 0 0 0
55 0 $new_statement->add_element($token->clone);
56 0 $token = $token->next_sibling;
57 }
58 0 $elem->snext_sibling->snext_sibling->remove;
59 0 $elem->snext_sibling->insert_after($new_list);
60 0 remove_trailing_whitespace($elem->snext_sibling->snext_sibling);
61 }
62 0 $elem->snext_sibling->insert_after($token);
63 0 $elem->snext_sibling->insert_after(
64 PPI::Token::Operator->new('->')
65 );
66 0 remove_trailing_whitespace($elem);
67 0 $elem->delete;
68  
69 0 return $self->transformation( $DESC, $EXPL, $elem );
70 }
71  
72 17 1;
73  
74 #-----------------------------------------------------------------------------
75  
76 __END__
« lib/Perl/ToPerl6/Transformer/CompoundStatements/RewriteLoops.pm ↑ Summary lib/Perl/ToPerl6/Exception/Configuration/Option/Transformer/ParameterValue.pm »