lib/Perl/ToPerl6/Transformer/Arrays/AddWhitespace.pm

filter: Statementstmt 84.8% 28 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 60.0% 3 / 5 totaltotal 84.3% 43 / 51 CC 1 SCAR 0.7
CC
1
Cov
85%
transform
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« lib/Perl/ToPerl6/Transformer/BasicTypes/Strings/RenameShell.pm ↑ Summary lib/Perl/ToPerl6/Transformer/CompoundStatements/RenameForeach.pm »
1 package Perl::ToPerl6::Transformer::Arrays::AddWhitespace;
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_ppi_token_quotelike_words_like };
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 qw(...) to qw (...)};
16 17 Readonly::Scalar my $EXPL =>
17 q{qw<>, qw{} &c are fine, but qw() is now a function call. Add ' ' to avoid this};
18  
19 #-----------------------------------------------------------------------------
20  
21 38 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
22 27 ▶sub default_necessity { return $NECESSITY_HIGHEST }
Subroutine default_necessity: called CC=1 SCAR=0.0
Pod documented
23 25 ▶sub default_themes { return qw(core bugs) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
24 4 ▶sub applies_to {
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
25 32 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
26 32 is_ppi_token_quotelike_words_like($_[1],qr{^qw\(})
27 }
28 4 }
29  
30 #-----------------------------------------------------------------------------
31 #
32 # Note to the reader:
33 #
34 # A PPI::Token::QuoteLike::Words object contains a single string which has the
35 # entire 'qw{...}' token. Therefore we can't add a Token::Whitespace between
36 # the 'qw' and '{..}' like we can with loops and conditionals.
37 #
38 0 ▶sub transform {
Subroutine transform: not called CC=1 SCAR=6.9
Pod undocumented
39 0 my ($self, $elem, $doc) = @_;
40 0 my $old_content = $elem->content;
41  
42 0 $old_content =~ s< ^ qw\( ><qw (>x;
43  
44 0 $elem->set_content( $old_content );
45  
46 0 return $self->transformation( $DESC, $EXPL, $elem );
47 }
48  
49 17 1;
50  
51 #-----------------------------------------------------------------------------
52  
53 __END__
« lib/Perl/ToPerl6/Transformer/BasicTypes/Strings/RenameShell.pm ↑ Summary lib/Perl/ToPerl6/Transformer/CompoundStatements/RenameForeach.pm »