Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 77977
Status: resolved
Priority: 0/
Queue: Perl-Critic

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

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



Subject: Perl::Tidy 20120619 breaks Perl::Critic::Policy::CodeLayout::RequireTidyCode
Perl::Tidy version 20120619 breaks CodeLayout::RequireTidyCode. There appear actually to be three breakages: 1) The stderr argument to perltidy() no longer takes a scalar reference. This is a documented change. Fortunately Perl::Critic already has IO::String as a dependency, so the solution is to instantiate an IO::String object from the $stderr variable, and pass that. 2) Perl::Tidy now chomps the perltidyrc string. This fails if it is passed a reference to a Readonly::Scalar, and throws an exception. The solution is to assign $EMPTY to a scalar variable, and pass that. 3) If you pass a scalar reference as the source argument to perltidy(), it is modified after the call -- the trailing newline is removed. The only solution I can come up with is more ad-hocery. Numbers 2 and 3 appear to me to be worthy of an RT ticket against Perl::Tidy. Patches for all the above are in preparation.
Changes committed as svn revision 4125. I have attached the svn diff in case someone wants to apply this before the next release.
Subject: RequireTidyCode.diff
--- lib/Perl/Critic/Policy/CodeLayout/RequireTidyCode.pm (revision 4123) +++ lib/Perl/Critic/Policy/CodeLayout/RequireTidyCode.pm (working copy) @@ -12,6 +12,7 @@ use warnings; use English qw(-no_match_vars); +use IO::String qw< >; use Readonly; use Perl::Tidy qw< >; @@ -49,7 +50,8 @@ # Set configuration if defined if (defined $self->{_perltidyrc} && $self->{_perltidyrc} eq $EMPTY) { - $self->{_perltidyrc} = \$EMPTY; + my $rc = $EMPTY; + $self->{_perltidyrc} = \$rc; } return $TRUE; @@ -92,10 +94,16 @@ # Trap Perl::Tidy errors, just in case it dies my $eval_worked = eval { + # Perl::Tidy 20120619 no longer accepts a scalar reference for stdio. + my $handle = IO::String->new( $stderr ); + # Since Perl::Tidy 20120619 modifies $source, we make a copy so + # we can get a good comparison. Doing an s/// on $source after the + # fact appears not to work with the previous Perl::Tidy. + my $source_copy = $source; Perl::Tidy::perltidy( - source => \$source, + source => \$source_copy, destination => \$dest, - stderr => \$stderr, + stderr => $handle, defined $self->{_perltidyrc} ? (perltidyrc => $self->{_perltidyrc}) : (), ); 1;
The relevant Perl::Tidy ticket is RT #77978.
This means that Perl::Critic is not currently installable without --force: t/20_policy_require_tidy_code.t ............... 1/6 # Failed test 'Tidy with one trailing newline' # at t/20_policy_require_tidy_code.t line 54. # got: '1' # expected: '0' # Failed test 'Tidy with two trailing newlines' # at t/20_policy_require_tidy_code.t line 70. # got: '1' # expected: '0' # Failed test 'Tidy with several trailing newlines' # at t/20_policy_require_tidy_code.t line 93. # got: '1' # expected: '0' # Failed test 'Tidy with heredoc' # at t/20_policy_require_tidy_code.t line 111. # got: '1' # expected: '0' # Failed test 'Tidy with shell escape' # at t/20_policy_require_tidy_code.t line 129. # got: '1' # expected: '0' # Looks like you failed 5 tests of 6. t/20_policy_require_tidy_code.t ............... Dubious, test returned 5 (wstat 1280, 0x500) Failed 5/6 subtests
This has been fixed and released as Perl-Critic-1.118. -- Jeffrey Thalhammer Imaginative Software Systems www.imaginative-software.com