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: 75300
Status: open
Priority: 0/
Queue: Perl-Critic

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

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



Subject: [PATCH] "use base 'Exporter'" => "use Exporter 'import'"
Download (untitled) / with headers
text/plain 508b
"base.pm" is an old module that is preserved for compatibility, but that is nowadays replaced by 'parent.pm' for the only common use case. The "use base 'Exporter'" is a special case that has a more efficient and completely documented way of avoiding 'base.pm': use Exporter 'import'; Here is a patch that basically does this: - use base 'Exporter'; + use Exporter 'import'; Making a Critic policy of this is left as an exercice to the reader. -- Olivier Mengué - http://perlresume.org/DOLMEN
Subject: use-base-Exporter.patch
Index: lib/Test/Perl/Critic/Policy.pm =================================================================== --- lib/Test/Perl/Critic/Policy.pm (révision 4115) +++ lib/Test/Perl/Critic/Policy.pm (copie de travail) @@ -33,7 +33,7 @@ #----------------------------------------------------------------------------- -use base 'Exporter'; +use Exporter 'import'; Readonly::Array our @EXPORT_OK => qw< all_policies_ok >; Readonly::Hash our %EXPORT_TAGS => (all => \@EXPORT_OK); Index: lib/Perl/Critic.pm =================================================================== --- lib/Perl/Critic.pm (révision 4115) +++ lib/Perl/Critic.pm (copie de travail) @@ -14,7 +14,7 @@ use English qw(-no_match_vars); use Readonly; -use base qw(Exporter); +use Exporter 'import'; use File::Spec; use List::MoreUtils qw< firstidx >; Index: lib/Perl/Critic/Command.pm =================================================================== --- lib/Perl/Critic/Command.pm (révision 4115) +++ lib/Perl/Critic/Command.pm (copie de travail) @@ -32,7 +32,7 @@ #----------------------------------------------------------------------------- -use base 'Exporter'; +use Exporter 'import'; Readonly::Array our @EXPORT_OK => qw< run >; Index: lib/Perl/Critic/Policy/Modules/ProhibitAutomaticExportation.pm =================================================================== --- lib/Perl/Critic/Policy/Modules/ProhibitAutomaticExportation.pm (révision 4115) +++ lib/Perl/Critic/Policy/Modules/ProhibitAutomaticExportation.pm (copie de travail) @@ -129,7 +129,7 @@ package Foo; - use base qw(Exporter); + use Exporter 'import'; our @EXPORT = qw(foo $bar @baz); # not ok our @EXPORT_OK = qw(foo $bar @baz); # ok our %EXPORT_TAGS = ( all => [ qw(foo $bar @baz) ] ); # ok Index: lib/Perl/Critic/Utils/PPI.pm =================================================================== --- lib/Perl/Critic/Utils/PPI.pm (révision 4115) +++ lib/Perl/Critic/Utils/PPI.pm (copie de travail) @@ -15,7 +15,7 @@ use Scalar::Util qw< blessed readonly >; -use base 'Exporter'; +use Exporter 'import'; our $VERSION = '1.117'; Index: lib/Perl/Critic/Utils/McCabe.pm =================================================================== --- lib/Perl/Critic/Utils/McCabe.pm (révision 4115) +++ lib/Perl/Critic/Utils/McCabe.pm (copie de travail) @@ -15,7 +15,7 @@ use Perl::Critic::Utils qw{ :data_conversion :classification }; -use base 'Exporter'; +use Exporter 'import'; #----------------------------------------------------------------------------- Index: lib/Perl/Critic/Utils/Constants.pm =================================================================== --- lib/Perl/Critic/Utils/Constants.pm (révision 4115) +++ lib/Perl/Critic/Utils/Constants.pm (copie de travail) @@ -14,7 +14,7 @@ use Perl::Critic::Utils qw{ $EMPTY hashify }; -use base 'Exporter'; +use Exporter 'import'; our $VERSION = '1.117'; Index: lib/Perl/Critic/Utils/DataConversion.pm =================================================================== --- lib/Perl/Critic/Utils/DataConversion.pm (révision 4115) +++ lib/Perl/Critic/Utils/DataConversion.pm (copie de travail) @@ -14,7 +14,7 @@ use Perl::Critic::Utils qw{ :characters :booleans }; -use base 'Exporter'; +use Exporter 'import'; our $VERSION = '1.117'; Index: lib/Perl/Critic/Utils/Perl.pm =================================================================== --- lib/Perl/Critic/Utils/Perl.pm (révision 4115) +++ lib/Perl/Critic/Utils/Perl.pm (copie de travail) @@ -11,7 +11,7 @@ use strict; use warnings; -use base 'Exporter'; +use Exporter 'import'; our $VERSION = '1.117'; Index: lib/Perl/Critic/Utils/POD.pm =================================================================== --- lib/Perl/Critic/Utils/POD.pm (révision 4115) +++ lib/Perl/Critic/Utils/POD.pm (copie de travail) @@ -22,7 +22,7 @@ use Perl::Critic::Exception::IO qw< throw_io >; use Perl::Critic::Utils qw< :characters >; -use base 'Exporter'; +use Exporter 'import'; our $VERSION = '1.117'; Index: lib/Perl/Critic/Exception.pm =================================================================== --- lib/Perl/Critic/Exception.pm (révision 4115) +++ lib/Perl/Critic/Exception.pm (copie de travail) @@ -22,7 +22,7 @@ }, ); -use base 'Exporter'; +use Exporter 'import'; #----------------------------------------------------------------------------- Index: lib/Perl/Critic/Utils.pm =================================================================== --- lib/Perl/Critic/Utils.pm (révision 4115) +++ lib/Perl/Critic/Utils.pm (copie de travail) @@ -25,7 +25,7 @@ use Perl::Critic::Exception::Fatal::Generic qw{ throw_generic }; use Perl::Critic::Utils::PPI qw< is_ppi_expression_or_generic_statement >; -use base 'Exporter'; +use Exporter 'import'; our $VERSION = '1.117'; Index: lib/Perl/Critic/TestUtils.pm =================================================================== --- lib/Perl/Critic/TestUtils.pm (révision 4115) +++ lib/Perl/Critic/TestUtils.pm (copie de travail) @@ -14,7 +14,7 @@ use English qw(-no_match_vars); use Readonly; -use base 'Exporter'; +use Exporter 'import'; use File::Path (); use File::Spec (); Index: lib/Perl/Critic/PolicyParameter.pm =================================================================== --- lib/Perl/Critic/PolicyParameter.pm (révision 4115) +++ lib/Perl/Critic/PolicyParameter.pm (copie de travail) @@ -12,7 +12,7 @@ use warnings; use Readonly; -use base 'Exporter'; +use Exporter 'import'; Readonly::Array our @EXPORT_OK => qw{ $NO_DESCRIPTION_AVAILABLE }; Index: lib/Perl/Critic/Theme.pm =================================================================== --- lib/Perl/Critic/Theme.pm (révision 4115) +++ lib/Perl/Critic/Theme.pm (copie de travail) @@ -13,7 +13,7 @@ use English qw(-no_match_vars); use Readonly; -use base qw{ Exporter }; +use Exporter 'import'; use List::MoreUtils qw(any); Index: inc/Perl/Critic/PolicySummaryGenerator.pm =================================================================== --- inc/Perl/Critic/PolicySummaryGenerator.pm (révision 4115) +++ inc/Perl/Critic/PolicySummaryGenerator.pm (copie de travail) @@ -11,7 +11,7 @@ use strict; use warnings; -use base qw< Exporter >; +use Exporter 'import'; use lib qw< blib lib >; use Carp qw< confess >; Index: inc/Perl/Critic/BuildUtilities.pm =================================================================== --- inc/Perl/Critic/BuildUtilities.pm (révision 4115) +++ inc/Perl/Critic/BuildUtilities.pm (copie de travail) @@ -15,7 +15,7 @@ our $VERSION = '1.116'; -use base qw{ Exporter }; +use Exporter 'import'; our @EXPORT_OK = qw< required_module_versions
Download (untitled) / with headers
text/plain 305b
Le 2012-02-25 12:42:14, DOLMEN a écrit : Show quoted text
> Here is a patch that basically does this: > - use base 'Exporter'; > + use Exporter 'import'; > > Making a Critic policy of this is left as an exercice to the reader.
The policy is now in bug #75329. -- Olivier Mengué - http://perlresume.org/DOLMEN
Download (untitled) / with headers
text/plain 526b
Please review this patch. Le 2012-02-25 12:42:14, DOLMEN a écrit : Show quoted text
> "base.pm" is an old module that is preserved for compatibility, but that > is nowadays replaced by 'parent.pm' for the only common use case. > The "use base 'Exporter'" is a special case that has a more efficient > and completely documented way of avoiding 'base.pm': > use Exporter 'import'; > > Here is a patch that basically does this: > - use base 'Exporter'; > + use Exporter 'import';
-- Olivier Mengué - http://perlresume.org/DOLMEN
Subject: Re: [rt.cpan.org #75300] [PATCH] "use base 'Exporter'" => "use Exporter 'import'"
Date: Wed, 25 Jul 2012 22:57:58 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <elliotjs [...] cpan.org>
Download (untitled) / with headers
text/plain 289b
On 7/25/12 4:30 AM, Olivier Mengué via RT wrote: Show quoted text
> Please review this patch.
The problem with this is it does not work with the version of Exporter included in perl 5.6, which is the minimum version supported by Perl::Critic. Exporter::import() doesn't exist until some time in 5.8.x.
Subject: Re: [rt.cpan.org #75300] [PATCH] "use base 'Exporter'" => "use Exporter 'import'"
Date: Wed, 25 Jul 2012 23:16:50 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <elliotjs [...] cpan.org>
Download (untitled) / with headers
text/plain 395b
On 7/25/12 10:57 PM, Elliot Shank wrote: Show quoted text
> On 7/25/12 4:30 AM, Olivier Mengué via RT wrote:
>> Please review this patch.
> > The problem with this is it does not work with the version of > Exporter included in perl 5.6, which is the minimum version supported > by Perl::Critic. Exporter::import() doesn't exist until some time in > 5.8.x.
Oh, yeah, parent.pm isn't in core perl until 5.10.1.
Download (untitled) / with headers
text/plain 480b
Le 2012-07-26 05:58:13, ELLIOTJS a écrit : Show quoted text
> On 7/25/12 4:30 AM, Olivier Mengué via RT wrote:
> > Please review this patch.
> > The problem with this is it does not work with the version of Exporter > included in perl 5.6, which is the minimum version supported by > Perl::Critic. Exporter::import() doesn't exist until some time in > 5.8.x.
You know, Exporter is also available from the CPAN, including 5.6 compatibility. -- Olivier Mengué - http://perlresume.org/DOLMEN
Download (untitled) / with headers
text/plain 358b
Le 2012-07-26 06:17:04, ELLIOTJS a écrit : Show quoted text
> Oh, yeah, parent.pm isn't in core perl until 5.10.1.
'parent.pm' is not used in my patch, so this is irrelevant. By the way, about the 'base.pm' being broken by design, see instead #70763 where we are requesting to fix the policy that recommends to use it. -- Olivier Mengué - http://perlresume.org/DOLMEN
Download (untitled) / with headers
text/plain 1.3k
On Thu Jul 26 04:00:35 2012, DOLMEN wrote: Show quoted text
> Le 2012-07-26 05:58:13, ELLIOTJS a écrit :
> > On 7/25/12 4:30 AM, Olivier Mengué via RT wrote:
> > > Please review this patch.
> > > > The problem with this is it does not work with the version of Exporter > > included in perl 5.6, which is the minimum version supported by > > Perl::Critic. Exporter::import() doesn't exist until some time in > > 5.8.x.
> > You know, Exporter is also available from the CPAN, including 5.6 > compatibility.
FWIW, Perl::Critic requires Exporter 5.63. What I remember about this is that old (but legal) versions of Exporter were really picky about how you mixed tags and subroutine names. This was causing problems on old (but supported) Perls, because none of the maintainers is actually running them. It seemed to me (or at least I recall it seeming to me) that there were three ways to deal with this: * Some developer had to test regularly under 5.6.2. I wasn't eager to volunteer, nor was I eager to ask someone else to volunteer. * Write a policy to keep this straight. Maybe this was the right thing to do, but at the time I didn't think so, or at least didn't feel like it. * Require a version of Exporter that would deal with the problem. The last is what I in fact did. The commit number (courtesy of 'svn blame') was 3919, and the RT ticket was 61071.
Download (untitled) / with headers
text/plain 746b
On Thu Jul 26 04:00:35 2012, DOLMEN wrote: Show quoted text
> Le 2012-07-26 05:58:13, ELLIOTJS a écrit :
> > On 7/25/12 4:30 AM, Olivier Mengué via RT wrote:
> > > Please review this patch.
> > > > The problem with this is it does not work with the version of Exporter > > included in perl 5.6, which is the minimum version supported by > > Perl::Critic. Exporter::import() doesn't exist until some time in > > 5.8.x.
> > You know, Exporter is also available from the CPAN, including 5.6 > compatibility.
Also FWIW, I _seem_ to remember, back in the deeps of time, ActivePerl having problems with 'use Exporter qw{ import };'. My memory may be faulty, and even if not it may have been fixed by now. Certainly you can't get 5.6 from ActiveState these days.
RT-Send-CC: elliotjs [...] cpan.org
Since we already require the newer Exporter, I see no reason not to apply this patch.
RT-Send-CC: elliotjs [...] cpan.org
Patch applied in revision 4148. Thanks for your contribution! -Jeff
Subject: Re: [rt.cpan.org #75300] [PATCH] "use base 'Exporter'" => "use Exporter 'import'"
Date: Thu, 26 Jul 2012 18:49:16 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <elliotjs [...] cpan.org>
Download (untitled) / with headers
text/plain 163b
On 7/26/12 10:23 AM, Tom Wyant via RT wrote: Show quoted text
> Certainly you can't get 5.6 from ActiveState these days.
Not for free. You can buy a support contract and get it.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.