Skip Menu |

This queue is for tickets about the Puppet-Tidy CPAN distribution.

Report information
The Basics
Id: 83072
Status: open
Priority: 0/
Queue: Puppet-Tidy

People
Owner: Nobody in particular
Requestors: blom [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Comment changing a little too greedy
A line like: source => "puppet:///modules/foo/bar" will be transformed into: source => "'puppet':#/modules/foo/bar" due to the '//' comment style converter. -- B10m
Patch attached -- B10m
Subject: bug_83072.patch
diff -Naur Puppet-Tidy-0.1/lib/Puppet/Tidy.pm Puppet-Tidy-0.1-new/lib/Puppet/Tidy.pm --- Puppet-Tidy-0.1/lib/Puppet/Tidy.pm 2012-12-10 11:49:01.000000000 +0100 +++ Puppet-Tidy-0.1-new/lib/Puppet/Tidy.pm 2013-01-31 15:45:43.000000000 +0100 @@ -190,7 +190,7 @@ next if $line =~ s/(\$\w+)/"$1"/g; } $line =~ s/"(.*?)":/\x27$1\x27:/g; # Double to single quoted - $line =~ s/(\w+):/\x27$1\x27:/g; # Bare word to single quoted + $line =~ s/(?!['"])(\w+):(?!.+['"]+)/\x27$1\x27:/g; # Bare word to single quoted } } @@ -252,7 +252,7 @@ foreach my $line (@$input) { - $line =~ s,//,#,; # C++ style + $line =~ s,(?!['"].+)//(?!.+['"]),#,; # C++ style $line =~ s,/\*(.*?)(\s+)\*/,#$1,; # C style } } diff -Naur Puppet-Tidy-0.1/t/bug_83072.t Puppet-Tidy-0.1-new/t/bug_83072.t --- Puppet-Tidy-0.1/t/bug_83072.t 1970-01-01 01:00:00.000000000 +0100 +++ Puppet-Tidy-0.1-new/t/bug_83072.t 2013-01-31 15:46:16.000000000 +0100 @@ -0,0 +1,27 @@ +use strict; +use Puppet::Tidy; +use Test::More tests => 2; + +# don't assume //.+ is a comment inside strings +my @output; +my $source = << 'EOF'; + source => 'puppet:///foo/bar'; +EOF + +my @should_be_output = << 'EOF'; + source => 'puppet:///foo/bar'; +EOF + +Puppet::Tidy::puppettidy(source => $source, destination => \@output); +is_deeply(@output, @should_be_output, "not messing within strings"); + +$source = << 'EOF'; + source => 'puppet:///foo/bar'; // replace me, please +EOF + +@should_be_output = << 'EOF'; + source => 'puppet:///foo/bar'; # replace me, please +EOF + +Puppet::Tidy::puppettidy(source => $source, destination => \@output); +is_deeply(@output, @should_be_output, "messing outside strings");
Subject: Re: [rt.cpan.org #83072] Comment changing a little too greedy
Date: Thu, 31 Jan 2013 17:13:27 +0100
To: "M. Blom via RT" <bug-Puppet-Tidy [...] rt.cpan.org>
From: Jasper Lievisse Adriaanse <jasper [...] mtier.org>
On Thu, Jan 31, 2013 at 10:01:31AM -0500, M. Blom via RT wrote: Show quoted text
> Queue: Puppet-Tidy > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=83072 > > > Patch attached > > -- > B10m
Thank you for the patch; I will merge it this weekend. -- Regards, Jasper Lievisse Adriaanse, Engineering team M:tier
On Thu Jan 31 11:13:59 2013, jasper@mtier.org wrote: Show quoted text
> On Thu, Jan 31, 2013 at 10:01:31AM -0500, M. Blom via RT wrote:
> > Queue: Puppet-Tidy > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=83072 > > > > > Patch attached > > > > -- > > B10m
> > Thank you for the patch; I will merge it this weekend.
After some more consideration I've merged your original diff. I will publish 0.2 later this month. Thanks!