PerlNitpick/Rule/RewriteHeredocAsQuotedString.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 35 CC 2 SCAR 12.0
CC
2
Cov
0%
rewrite
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.3
1 package App::PerlNitpick::Rule::RewriteHeredocAsQuotedString;
2  
3 use Moose;
4 use String::PerlQuote qw(double_quote);
5 use PPI::Document;
6  
7 sub rewrite {
8 my ($self, $doc) = @_;
9 my $heredocs = $doc->find('PPI::Token::HereDoc') or return;
10  
11 for my $heredoc (@{ $heredocs }) {
12 # Only handle the heredoc that does not interpolate variables.
13 next unless $heredoc->content =~ /'\z/;
14  
15 my $content = join '', $heredoc->heredoc;
16 my $tok_content = double_quote($content);
17 my $tok = PPI::Token::Quote::Double->new( $tok_content );
18 $heredoc->insert_before($tok);
19 $heredoc->remove;
20 }
21  
22 return $doc;
23 }
24  
25 no Moose;
26 1;
27  
28  
29 __END__