lib/Perl/ToPerl6/Transformer/Variables/RewriteMatchVariables.pm

filter: Statementstmt 78.7% 26 / 33 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 50.0% 3 / 6 totaltotal 75.0% 42 / 56 CC 3 SCAR 6.0
CC
3
Cov
73%
transform
6.0
__ANON__
2.1
applies_to
1.0
CRAP 1.8
« lib/Perl/ToPerl6/Transformer/Regexes/StandardizeDelimiters.pm ↑ Summary lib/Perl/ToPerl6/Transformer/Regexes/SwapModifiers.pm »
1 package Perl::ToPerl6::Transformer::Variables::RewriteMatchVariables;
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  
10 17 ▶use base 'Perl::ToPerl6::Transformer';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #-----------------------------------------------------------------------------
13  
14 17 Readonly::Scalar my $DESC => q{Transform $1..$n to $0..$n-1};
15 17 Readonly::Scalar my $EXPL => q{Transform $1..$n to $0..$n-1};
16  
17 #-----------------------------------------------------------------------------
18  
19 # '$1' => '$0', # And so on, make sure they don't get modified twice
20 # '$2' => '$1',
21 # '$3' => '$2',
22 # '$4' => '$1',
23  
24 #-----------------------------------------------------------------------------
25 #
26 # Make sure this is run *after* Variables::RewriteSpecialVariables.
27 #
28  
29 32 ▶sub run_after { return 'Variables::RewriteSpecialVariables' }
Subroutine run_after: called CC=1 SCAR=0.0
Pod undocumented
30 39 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
31 27 ▶sub default_necessity { return $NECESSITY_HIGHEST }
Subroutine default_necessity: called CC=1 SCAR=0.0
Pod documented
32 24 ▶sub default_themes { return qw( core ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
33 5 ▶sub applies_to {
Subroutine applies_to: called CC=1 SCAR=0.2
Pod documented
34 78 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
35 78 ▶ $_[1]->isa('PPI::Token::Magic') and
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Magic") and $_[1]->content =~ / ^ \$ \d+ $ /x 0 78 78
36 $_[1]->content =~ / ^ \$ \d+ $ /x
37 }
38 5 }
39  
40 #-----------------------------------------------------------------------------
41  
42 0 ▶sub transform {
Subroutine transform: not called CC=2 SCAR=17.9
Pod undocumented
43 0 my ($self, $elem, $doc) = @_;
44 0 my $old_content = $elem->content;
45  
46 0 $old_content =~ m/ ^ \$ (\d+) $ /x;
47  
48 0 ▶ return if $1 <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $1 <= 0 0 0 0
49  
50 0 my $new_content = q{$} . ($1 - 1);
51  
52 0 $elem->set_content( $new_content );
53  
54 0 return $self->transformation( $DESC, $EXPL, $elem );
55 }
56  
57 17 1;
58  
59 #-----------------------------------------------------------------------------
60  
61 __END__
« lib/Perl/ToPerl6/Transformer/Regexes/StandardizeDelimiters.pm ↑ Summary lib/Perl/ToPerl6/Transformer/Regexes/SwapModifiers.pm »