lib/Perl/ToPerl6/Transformer/Regexes/StandardizeDelimiters.pm

filter: Statementstmt 59.5% 25 / 42 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 60.0% 3 / 5 totaltotal 67.2% 41 / 61 CC 3 SCAR 6.2
CC
3
Cov
61%
transform
6.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.9
« lib/Perl/ToPerl6/Transformer/Variables/RewriteSpecialVariables.pm ↑ Summary lib/Perl/ToPerl6/Transformer/Variables/RewriteMatchVariables.pm »
1 package Perl::ToPerl6::Transformer::Regexes::StandardizeDelimiters;
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{Regex delimiters can no longer be alphanumeric};
15 17 Readonly::Scalar my $EXPL => q{Regex delimiters can no longer be alphanumeric};
16  
17 #-----------------------------------------------------------------------------
18  
19 38 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
20 27 ▶sub default_necessity { return $NECESSITY_HIGHEST }
Subroutine default_necessity: called CC=1 SCAR=0.0
Pod documented
21 24 ▶sub default_themes { return qw( core ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
22 5 ▶sub applies_to {
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
23 78 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
24 $_[1]->isa('PPI::Token::Regexp') and
25 78 ▶ $_[1]->{sections}[0]{type} =~ /[a-zA-Z0-9#]/
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Regexp") and $_[1]{"sections"}[0]{"type"} =~ /[a-zA-Z0-9#]/ 1 77 78
26 }
27 5 }
28  
29 #-----------------------------------------------------------------------------
30  
31 0 ▶sub transform {
Subroutine transform: not called CC=2 SCAR=17.9
Pod undocumented
32 0 my ($self, $elem, $doc) = @_;
33  
34 0 my @content;
35 0 for ( @{ $elem->{sections} } ) {
36 0 my $content = substr( $elem->content, $_->{position}, $_->{size} );
37 0 $content =~ s{/}{\\/}g; # XXX this could be a problem.
38 0 $_->{position}--; # Account for the eventual lack of whitespace.
39 0 $_->{type} = '//';
40 0 push @content, $content;
41 }
42  
43 0 my ( $operator ) = $elem->content =~ m{^(m|s|y|tr)};
44 0 my $num_modifiers = keys %{ $elem->get_modifiers };
45 0 my $modifiers = substr( $elem->content, -$num_modifiers, $num_modifiers );
46  
47 0 my $new_content = $operator . '/' .
48 join('/', @content) . '/' .
49 $modifiers;
50  
51 0 $elem->{separator} = '/';
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/Variables/RewriteSpecialVariables.pm ↑ Summary lib/Perl/ToPerl6/Transformer/Variables/RewriteMatchVariables.pm »