Subject: | [PATCH] "use base 'Exporter'" => "use Exporter 'import'" |
"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