[Rt-commit] rt branch, 4.2/shredder-critic, created. rt-4.2.5-152-gefdabcd

Alex Vandiver alexmv at bestpractical.com
Mon Jul 7 14:38:55 EDT 2014


The branch, 4.2/shredder-critic has been created
        at  efdabcdb08f655c99bcf9d5f54c6a36c3ca7764a (commit)

- Log -----------------------------------------------------------------
commit e4cca37af61526f34524c949fb47f5971f3f2810
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Jul 7 11:59:14 2014 -0400

    Stop using map in void context for its aliasing effect

diff --git a/lib/RT/Shredder/Plugin/Attachments.pm b/lib/RT/Shredder/Plugin/Attachments.pm
index 05f264e..d7bb84b 100644
--- a/lib/RT/Shredder/Plugin/Attachments.pm
+++ b/lib/RT/Shredder/Plugin/Attachments.pm
@@ -132,7 +132,7 @@ sub Run
     }
     return (0, "Internal error: '". $sth->err ."'. Please send bug report.") if $sth->err;
 
-    map { $_ = "RT::Attachment-$_" } @objs;
+    @objs = map {"RT::Attachment-$_"} @objs;
 
     return (1, @objs);
 }

commit df8ee511a42ead6a9c338e7123cc17d8a0fba3da
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri May 23 15:30:51 2014 -0400

    Switch to using UNIVERSAL::require rather than eval "require $_"

diff --git a/bin/rt-crontool.in b/bin/rt-crontool.in
index db2cb04..668b325 100644
--- a/bin/rt-crontool.in
+++ b/bin/rt-crontool.in
@@ -287,8 +287,7 @@ sub get_template {
 
 sub load_module {
     my $modname = shift;
-    eval "require $modname";
-    if ($@) {
+    unless ($modname->require) {
         die loc( "Failed to load module [_1]. ([_2])", $modname, $@ );
     }
 
diff --git a/lib/RT.pm b/lib/RT.pm
index 21ce36a..6d3d5d2 100644
--- a/lib/RT.pm
+++ b/lib/RT.pm
@@ -56,6 +56,7 @@ package RT;
 use File::Spec ();
 use Cwd ();
 use Scalar::Util qw(blessed);
+use UNIVERSAL::require;
 
 use vars qw($Config $System $SystemUser $Nobody $Handle $Logger $_Privileged $_Unprivileged $_INSTALL_MODE);
 
@@ -495,8 +496,7 @@ sub InitClasses {
         }
 
         foreach my $class ( grep $_, RT->Config->Get('CustomFieldValuesSources') ) {
-            local $@;
-            eval "require $class; 1" or $RT::Logger->error(
+            $class->require or $RT::Logger->error(
                 "Class '$class' is listed in CustomFieldValuesSources option"
                 ." in the config, but we failed to load it:\n$@\n"
             );
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 7842e57..7c75d0e 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -604,9 +604,7 @@ our %META;
             my $self  = shift;
             my $value = shift;
             return if $value;
-            return if $INC{'GraphViz.pm'};
-            local $@;
-            return if eval {require GraphViz; 1};
+            return if GraphViz->require;
             $RT::Logger->debug("You've enabled GraphViz, but we couldn't load the module: $@");
             $self->Set( DisableGraphViz => 1 );
         },
@@ -617,9 +615,7 @@ our %META;
             my $self  = shift;
             my $value = shift;
             return if $value;
-            return if $INC{'GD.pm'};
-            local $@;
-            return if eval {require GD; 1};
+            return if GD->require;
             $RT::Logger->debug("You've enabled GD, but we couldn't load the module: $@");
             $self->Set( DisableGD => 1 );
         },
diff --git a/lib/RT/Crypt.pm b/lib/RT/Crypt.pm
index d89cdcd..9754d3d 100644
--- a/lib/RT/Crypt.pm
+++ b/lib/RT/Crypt.pm
@@ -277,7 +277,7 @@ sub LoadImplementation {
     my $class = 'RT::Crypt::'. $proto;
     return $cache{ $class } if exists $cache{ $class };
 
-    if (eval "require $class; 1") {
+    if ($class->require) {
         return $cache{ $class } = $class;
     } else {
         RT->Logger->warn( "Could not load $class: $@" );
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index efa7c81..21427f7 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -601,7 +601,7 @@ sub Values {
 
     my $class = $self->ValuesClass;
     if ( $class ne 'RT::CustomFieldValues') {
-        eval "require $class" or die "$@";
+        $class->require or die "Can't load $class: $@";
     }
     my $cf_values = $class->new( $self->CurrentUser );
     # if the user has no rights, return an empty object
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 9c1158b..5fc36f6 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -86,11 +86,10 @@ sub FinalizeDatabaseType {
     my $db_type = RT->Config->Get('DatabaseType');
     my $package = "DBIx::SearchBuilder::Handle::$db_type";
 
-    unless (eval "require $package; 1;") {
+    $package->require or
         die "Unable to load DBIx::SearchBuilder database handle for '$db_type'.\n".
             "Perhaps you've picked an invalid database type or spelled it incorrectly.\n".
             $@;
-    }
 
     @RT::Handle::ISA = ($package);
 
diff --git a/lib/RT/I18N.pm b/lib/RT/I18N.pm
index 65fc638..7df5e89 100644
--- a/lib/RT/I18N.pm
+++ b/lib/RT/I18N.pm
@@ -537,8 +537,8 @@ use Encode::Guess to try to figure it out the string's encoding.
 
 =cut
 
-use constant HAS_ENCODE_GUESS => do { local $@; eval { require Encode::Guess; 1 } };
-use constant HAS_ENCODE_DETECT => do { local $@; eval { require Encode::Detect::Detector; 1 } };
+use constant HAS_ENCODE_GUESS => Encode::Guess->require;
+use constant HAS_ENCODE_DETECT => Encode::Detect::Detector->require;
 
 sub _GuessCharset {
     my $fallback = _CanonicalizeCharset('iso-8859-1');
@@ -636,8 +636,7 @@ sub _CanonicalizeCharset {
         return 'gbk';
     }
     elsif ( $charset =~ /^(?:(?:big5(-1984|-2003|ext|plus))|cccii|unisys|euc-tw|gb18030|(?:cns11643-\d+))$/ ) {
-        eval { require Encode::HanExtra };
-        if ( $@ ) {
+        unless ( Encode::HanExtra->require ) {
             RT->Logger->error("Please install Encode::HanExtra to handle $charset");
         }
         return $charset;
diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index facdb38..75669ce 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -55,7 +55,6 @@ use Email::Address;
 use MIME::Entity;
 use RT::EmailParser;
 use File::Temp;
-use UNIVERSAL::require;
 use Mail::Mailer ();
 use Text::ParseWords qw/shellwords/;
 
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 6b87aa8..f82cf57 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -3971,7 +3971,7 @@ sub _NewScrubber {
     require HTML::Scrubber;
     my $scrubber = HTML::Scrubber->new();
 
-    if (eval "require HTML::Gumbo; 1") {
+    if (HTML::Gumbo->require) {
         no warnings 'redefine';
         my $orig = \&HTML::Scrubber::scrub;
         *HTML::Scrubber::scrub = sub {
diff --git a/lib/RT/Interface/Web/Handler.pm b/lib/RT/Interface/Web/Handler.pm
index cf94610..7260d26 100644
--- a/lib/RT/Interface/Web/Handler.pm
+++ b/lib/RT/Interface/Web/Handler.pm
@@ -106,7 +106,6 @@ sub InitSessionDir {
 }
 
 
-use UNIVERSAL::require;
 sub NewHandler {
     my $class = shift;
     $class->require or die $!;
diff --git a/lib/RT/Interface/Web/Session.pm b/lib/RT/Interface/Web/Session.pm
index 368b51a..887a645 100644
--- a/lib/RT/Interface/Web/Session.pm
+++ b/lib/RT/Interface/Web/Session.pm
@@ -84,8 +84,7 @@ sub Class {
     my $class = RT->Config->Get('WebSessionClass')
              || $self->Backends->{RT->Config->Get('DatabaseType')}
              || 'Apache::Session::File';
-    eval "require $class";
-    die $@ if $@;
+    $class->require or die "Can't load $class: $@";
     return $class;
 }
 
diff --git a/lib/RT/Migrate/Serializer.pm b/lib/RT/Migrate/Serializer.pm
index 0866dea..2c23833 100644
--- a/lib/RT/Migrate/Serializer.pm
+++ b/lib/RT/Migrate/Serializer.pm
@@ -162,9 +162,9 @@ sub PushAll {
     $self->PushCollections(qw(Articles), map { ($_, "Object$_") } qw(Classes Topics));
 
     # Custom Fields
-    if (eval "require RT::ObjectCustomFields; 1") {
+    if (RT::ObjectCustomFields->require) {
         $self->PushCollections(map { ($_, "Object$_") } qw(CustomFields CustomFieldValues));
-    } elsif (eval "require RT::TicketCustomFieldValues; 1") {
+    } elsif (RT::TicketCustomFieldValues->require) {
         $self->PushCollections(qw(CustomFields CustomFieldValues TicketCustomFieldValues));
     }
 
@@ -184,7 +184,7 @@ sub PushCollections {
     for my $type (@_) {
         my $class = "RT::\u$type";
 
-        eval "require $class; 1" or next;
+        $class->require or next;
         my $collection = $class->new( RT->SystemUser );
         $collection->FindAllRows;   # be explicit
         $collection->CleanSlate;    # some collections (like groups and users) join in _Init
@@ -288,7 +288,7 @@ sub PushBasics {
         $self->PushObj( $groups );
     }
 
-    if (eval "require RT::Articles; 1") {
+    if (RT::Articles->require) {
         $self->PushCollections(qw(Topics Classes));
     }
 
diff --git a/lib/RT/Ruleset.pm b/lib/RT/Ruleset.pm
index e6267da..fe4e933 100644
--- a/lib/RT/Ruleset.pm
+++ b/lib/RT/Ruleset.pm
@@ -52,7 +52,6 @@ use warnings;
 
 
 use base 'Class::Accessor::Fast';
-use UNIVERSAL::require;
 
 __PACKAGE__->mk_accessors(qw(Name Rules));
 
diff --git a/lib/RT/ScripAction.pm b/lib/RT/ScripAction.pm
index feb1b2c..883c169 100644
--- a/lib/RT/ScripAction.pm
+++ b/lib/RT/ScripAction.pm
@@ -66,6 +66,7 @@ use warnings;
 
 use base 'RT::Record';
 
+
 sub Table {'ScripActions'}
 
 use RT::Template;
@@ -170,7 +171,7 @@ sub LoadAction  {
     my $module = $1;
     my $type = "RT::Action::". $module;
 
-    eval "require $type" || die "Require of $type failed.\n$@\n";
+    $type->require or die "Require of $type action module failed.\n$@\n";
 
     return $self->{'Action'} = $type->new(
         %args,
diff --git a/lib/RT/ScripCondition.pm b/lib/RT/ScripCondition.pm
index 8a59c1f..0b1d682 100644
--- a/lib/RT/ScripCondition.pm
+++ b/lib/RT/ScripCondition.pm
@@ -75,6 +75,7 @@ use warnings;
 
 use base 'RT::Record';
 
+
 sub Table {'ScripConditions'}
 
 
@@ -161,7 +162,7 @@ sub LoadCondition  {
     my $module = $1;
     my $type = "RT::Condition::". $module;
 
-    eval "require $type" || die "Require of $type failed.\n$@\n";
+    $type->require or die "Require of $type condition module failed.\n$@\n";
 
     $self->{'Condition'}  = $type->new ( 'ScripConditionObj' => $self,
                                          'TicketObj' => $args{'TicketObj'},
diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
index 1e67a4d..c6fc9de 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -368,8 +368,7 @@ sub CastObjectsToRecords
         RT::Shredder::Exception->throw( "Unsupported class $class" )
               unless $class =~ /^\w+(::\w+)*$/;
         $class = 'RT::'. $class unless $class =~ /^RTx?::/i;
-        eval "require $class";
-        die "Couldn't load '$class' module" if $@;
+        $class->require or die "Failed to load $class: $@";
         my $obj = $class->new( RT->SystemUser );
         die "Couldn't construct new '$class' object" unless $obj;
         $obj->Load( $id );
diff --git a/lib/RT/Shredder/Plugin.pm b/lib/RT/Shredder/Plugin.pm
index 896b5d8..d929eca 100644
--- a/lib/RT/Shredder/Plugin.pm
+++ b/lib/RT/Shredder/Plugin.pm
@@ -137,7 +137,7 @@ sub List
     delete $res{'Base'};
     foreach my $name( keys %res ) {
         my $class = join '::', qw(RT Shredder Plugin), $name;
-        unless( eval "require $class" ) {
+        unless( $class->require ) {
             delete $res{ $name };
             next;
         }
@@ -171,9 +171,8 @@ sub LoadByName
     my $name = shift or return (0, "Name not specified");
     $name =~ /^\w+(::\w+)*$/ or return (0, "Invalid plugin name");
 
-    local $@;
     my $plugin = "RT::Shredder::Plugin::$name";
-    eval "require $plugin" or return( 0, $@ );
+    $plugin->require or return( 0, "Failed to load $plugin" );
     return wantarray ? ( 0, "Plugin '$plugin' has no method new") : 0 unless $plugin->can('new');
 
     my $obj = eval { $plugin->new( @_ ) };
diff --git a/lib/RT/Test/GnuPG.pm b/lib/RT/Test/GnuPG.pm
index 9782822..f47a5d3 100644
--- a/lib/RT/Test/GnuPG.pm
+++ b/lib/RT/Test/GnuPG.pm
@@ -65,7 +65,7 @@ sub import {
     my $t     = $class->builder;
 
     $t->plan( skip_all => 'GnuPG required.' )
-      unless eval { require GnuPG::Interface; 1 };
+      unless GnuPG::Interface->require;
     $t->plan( skip_all => 'gpg executable is required.' )
       unless RT::Test->find_executable('gpg');
 
diff --git a/sbin/rt-dump-metadata.in b/sbin/rt-dump-metadata.in
index 6effcfb..c7c5a74 100644
--- a/sbin/rt-dump-metadata.in
+++ b/sbin/rt-dump-metadata.in
@@ -260,7 +260,7 @@ OBJECT:
             }
         }
 
-        if ( eval { require RT::Attributes; 1 } ) {
+        if ( RT::Attributes->require ) {
             my $attributes = $obj->Attributes;
             while ( my $attribute = $attributes->Next ) {
                 my $content = $attribute->Content;
diff --git a/sbin/rt-serializer.in b/sbin/rt-serializer.in
index 33cd3d3..881a20b 100644
--- a/sbin/rt-serializer.in
+++ b/sbin/rt-serializer.in
@@ -196,8 +196,7 @@ sub estimate {
     for my $class (@types) {
         print "Estimating $class count...";
         my $collection = $class . "s";
-        eval "require $collection";
-        unless ($@) {
+        if ($collection->require) {
             my $objs = $collection->new( RT->SystemUser );
             $objs->FindAllRows;
             $objs->UnLimit;
diff --git a/share/html/Admin/Elements/EditCustomFieldValuesSource b/share/html/Admin/Elements/EditCustomFieldValuesSource
index 3aecf7c..557f62b 100644
--- a/share/html/Admin/Elements/EditCustomFieldValuesSource
+++ b/share/html/Admin/Elements/EditCustomFieldValuesSource
@@ -60,9 +60,7 @@ my @sources;
 foreach my $class( 'RT::CustomFieldValues', RT->Config->Get('CustomFieldValuesSources') ) {
     next unless $class;
 
-    local $@;
-    eval "require $class";
-    if( $@ ) {
+    unless ($class->require) {
         $RT::Logger->crit("Couldn't load class '$class': $@");
         next;
     }
diff --git a/share/html/Admin/Tools/Theme.html b/share/html/Admin/Tools/Theme.html
index 1f87127..38ef606 100644
--- a/share/html/Admin/Tools/Theme.html
+++ b/share/html/Admin/Tools/Theme.html
@@ -246,7 +246,7 @@ my $colors;
 my $valid_image_types;
 my $analyze_img = sub {
     return undef if RT->Config->Get('DisableGD');
-    return undef unless eval { require Convert::Color; 1 };
+    return undef unless Convert::Color->require;
 
     require GD;
 
diff --git a/t/api/i18n_guess.t b/t/api/i18n_guess.t
index 956cb15..325fce7 100644
--- a/t/api/i18n_guess.t
+++ b/t/api/i18n_guess.t
@@ -6,8 +6,8 @@ use RT::Test tests => 16;
 
 use Encode qw(encode);
 
-use constant HAS_ENCODE_GUESS => do { local $@; eval { require Encode::Guess; 1 } };
-use constant HAS_ENCODE_DETECT => do { local $@; eval { require Encode::Detect::Detector; 1 } };
+use constant HAS_ENCODE_GUESS => Encode::Guess->require;
+use constant HAS_ENCODE_DETECT => Encode::Detect::Detector->require;
 
 my $string = "\x{442}\x{435}\x{441}\x{442} \x{43f}\x{43e}\x{434}\x{434}\x{435}\x{440}\x{436}\x{43a}\x{430}";
 
diff --git a/t/mail/dashboard-chart-with-utf8.t b/t/mail/dashboard-chart-with-utf8.t
index 79f5f0e..259c6a1 100644
--- a/t/mail/dashboard-chart-with-utf8.t
+++ b/t/mail/dashboard-chart-with-utf8.t
@@ -1,16 +1,10 @@
 use strict;
 use warnings;
 
-BEGIN {
-    require RT::Test;
-
-    if (eval { require GD }) {
-        RT::Test->import(tests => 15);
-    }
-    else {
-        RT::Test->import(skip_all => 'GD required.');
-    }
-}
+use RT::Test tests => undef;
+
+plan skip_all => 'GD required'
+    unless GD->require;
 
 use utf8;
 
@@ -90,3 +84,5 @@ if ( my $io = $handle->open('r') ) {
 }
 is( $mail_image_data, $image, 'image in mail is the same one in web' );
 
+undef $m;
+done_testing;
diff --git a/t/security/CVE-2011-5092-graph-links.t b/t/security/CVE-2011-5092-graph-links.t
index 31ef266..660a3f4 100644
--- a/t/security/CVE-2011-5092-graph-links.t
+++ b/t/security/CVE-2011-5092-graph-links.t
@@ -2,8 +2,9 @@ use strict;
 use warnings;
 
 use RT::Test tests => undef;
+
 plan skip_all => 'GraphViz required.'
-    unless eval { require GraphViz; 1 };
+    unless GraphViz->require;
 
 my ($base, $m) = RT::Test->started_ok;
 $m->login;
diff --git a/t/web/charting.t b/t/web/charting.t
index 9b76f61..5131f9c 100644
--- a/t/web/charting.t
+++ b/t/web/charting.t
@@ -1,16 +1,10 @@
 use strict;
 use warnings;
 
-BEGIN {
-    require RT::Test;
-
-    if (eval { require GD; 1 }) {
-        RT::Test->import(tests => undef);
-    }
-    else {
-        RT::Test->import(skip_all => 'GD required.');
-    }
-}
+use RT::Test tests => undef;
+
+plan skip_all => 'GD required'
+    unless GD->require;
 
 for my $n (1..7) {
     my $ticket = RT::Ticket->new( RT->SystemUser );

commit a9cd7d1886d4dc7afccd68753eae1e9539a13933
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sun Feb 6 04:03:26 2011 +0300

    Move all code after package definition

diff --git a/lib/RT/Shredder/ACE.pm b/lib/RT/Shredder/ACE.pm
index 737dacf..6676c0c 100644
--- a/lib/RT/Shredder/ACE.pm
+++ b/lib/RT/Shredder/ACE.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::ACE ();
 package RT::ACE;
+use RT::ACE ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/Attachment.pm b/lib/RT/Shredder/Attachment.pm
index ffd4165..9cf3261 100644
--- a/lib/RT/Shredder/Attachment.pm
+++ b/lib/RT/Shredder/Attachment.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::Attachment ();
 package RT::Attachment;
+use RT::Attachment ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/CachedGroupMember.pm b/lib/RT/Shredder/CachedGroupMember.pm
index 7ad2869..52bd8c9 100644
--- a/lib/RT/Shredder/CachedGroupMember.pm
+++ b/lib/RT/Shredder/CachedGroupMember.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::CachedGroupMember ();
 package RT::CachedGroupMember;
+use RT::CachedGroupMember ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/CustomField.pm b/lib/RT/Shredder/CustomField.pm
index 125d103..920abd2 100644
--- a/lib/RT/Shredder/CustomField.pm
+++ b/lib/RT/Shredder/CustomField.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::CustomField ();
 package RT::CustomField;
+use RT::CustomField ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/CustomFieldValue.pm b/lib/RT/Shredder/CustomFieldValue.pm
index 08e19ae..d6dd362 100644
--- a/lib/RT/Shredder/CustomFieldValue.pm
+++ b/lib/RT/Shredder/CustomFieldValue.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::CustomFieldValue ();
 package RT::CustomFieldValue;
+use RT::CustomFieldValue ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/Group.pm b/lib/RT/Shredder/Group.pm
index f1fe7e7..d478dfd 100644
--- a/lib/RT/Shredder/Group.pm
+++ b/lib/RT/Shredder/Group.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::Group ();
 package RT::Group;
+use RT::Group ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/GroupMember.pm b/lib/RT/Shredder/GroupMember.pm
index b9a7e08..41536e7 100644
--- a/lib/RT/Shredder/GroupMember.pm
+++ b/lib/RT/Shredder/GroupMember.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::GroupMember ();
 package RT::GroupMember;
+use RT::GroupMember ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/Link.pm b/lib/RT/Shredder/Link.pm
index a561db9..e4e5f33 100644
--- a/lib/RT/Shredder/Link.pm
+++ b/lib/RT/Shredder/Link.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::Link ();
 package RT::Link;
+use RT::Link ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/ObjectCustomFieldValue.pm b/lib/RT/Shredder/ObjectCustomFieldValue.pm
index 440645e..4d52755 100644
--- a/lib/RT/Shredder/ObjectCustomFieldValue.pm
+++ b/lib/RT/Shredder/ObjectCustomFieldValue.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::ObjectCustomFieldValue ();
 package RT::ObjectCustomFieldValue;
+use RT::ObjectCustomFieldValue ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/Principal.pm b/lib/RT/Shredder/Principal.pm
index e51f223..33ab462 100644
--- a/lib/RT/Shredder/Principal.pm
+++ b/lib/RT/Shredder/Principal.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::Principal ();
 package RT::Principal;
+use RT::Principal ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/Queue.pm b/lib/RT/Shredder/Queue.pm
index d95c213..a4a9e1a 100644
--- a/lib/RT/Shredder/Queue.pm
+++ b/lib/RT/Shredder/Queue.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::Queue ();
 package RT::Queue;
+use RT::Queue ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/Record.pm b/lib/RT/Shredder/Record.pm
index ebfa7c2..cad04e6 100644
--- a/lib/RT/Shredder/Record.pm
+++ b/lib/RT/Shredder/Record.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::Record ();
 package RT::Record;
+use RT::Record ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/Scrip.pm b/lib/RT/Shredder/Scrip.pm
index c4953c6..25a2dbf 100644
--- a/lib/RT/Shredder/Scrip.pm
+++ b/lib/RT/Shredder/Scrip.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::Scrip ();
 package RT::Scrip;
+use RT::Scrip ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/ScripAction.pm b/lib/RT/Shredder/ScripAction.pm
index 1bb94b8..f19b457 100644
--- a/lib/RT/Shredder/ScripAction.pm
+++ b/lib/RT/Shredder/ScripAction.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::ScripAction ();
 package RT::ScripAction;
+use RT::ScripAction ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/ScripCondition.pm b/lib/RT/Shredder/ScripCondition.pm
index cec8bec..cf43686 100644
--- a/lib/RT/Shredder/ScripCondition.pm
+++ b/lib/RT/Shredder/ScripCondition.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::ScripCondition ();
 package RT::ScripCondition;
+use RT::ScripCondition ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/Template.pm b/lib/RT/Shredder/Template.pm
index b606a64..f1f0b33 100644
--- a/lib/RT/Shredder/Template.pm
+++ b/lib/RT/Shredder/Template.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::Template ();
 package RT::Template;
+use RT::Template ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/Ticket.pm b/lib/RT/Shredder/Ticket.pm
index b1b39a2..e8f3c2a 100644
--- a/lib/RT/Shredder/Ticket.pm
+++ b/lib/RT/Shredder/Ticket.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::Ticket ();
 package RT::Ticket;
+use RT::Ticket ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/Transaction.pm b/lib/RT/Shredder/Transaction.pm
index b4f00ba..1538a32 100644
--- a/lib/RT/Shredder/Transaction.pm
+++ b/lib/RT/Shredder/Transaction.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::Transaction ();
 package RT::Transaction;
+use RT::Transaction ();
 
 use strict;
 use warnings;
diff --git a/lib/RT/Shredder/User.pm b/lib/RT/Shredder/User.pm
index 41f3d02..75bf1a0 100644
--- a/lib/RT/Shredder/User.pm
+++ b/lib/RT/Shredder/User.pm
@@ -46,8 +46,8 @@
 #
 # END BPS TAGGED BLOCK }}}
 
-use RT::User ();
 package RT::User;
+use RT::User ();
 
 use strict;
 use warnings;

commit cb8d2f24163e3c5093eefb81f726a3f397a55baa
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sun Feb 6 04:43:32 2011 +0300

    decriticize shredder's code

diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
index c6fc9de..ec2d677 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -288,6 +288,7 @@ sub Init
     %opt = @_;
     RT::LoadConfig();
     RT::Init();
+    return;
 }
 
 =head4 new
@@ -304,8 +305,7 @@ sub new
 {
     my $proto = shift;
     my $self = bless( {}, ref $proto || $proto );
-    $self->_Init( @_ );
-    return $self;
+    return $self->_Init( @_ );
 }
 
 sub _Init
@@ -315,6 +315,7 @@ sub _Init
     $self->{'cache'}        = {};
     $self->{'resolver'}     = {};
     $self->{'dump_plugins'} = [];
+    return $self;
 }
 
 =head4 CastObjectsToRecords( Objects => undef )
@@ -556,6 +557,7 @@ sub WipeoutAll
         next if $cache_val->{'State'} & (WIPED | IN_WIPING);
         $self->Wipeout( Object => $cache_val->{'Object'} );
     }
+    return;
 }
 
 sub Wipeout
@@ -576,6 +578,7 @@ sub Wipeout
         die $error if RT::Shredder::Exception::Info->caught;
         die "Couldn't wipeout object: $error";
     }
+    return;
 }
 
 sub _Wipeout
@@ -773,6 +776,7 @@ sub DumpObject {
         my ($state, $msg) = $_->Run( %args );
         die "Couldn't run plugin: $msg" unless $state;
     }
+    return;
 }
 
 { my $mark = 1; # XXX: integer overflows?
@@ -791,6 +795,7 @@ sub PopDumpMark {
         my ($state, $msg) = $_->PopMark( @_ );
         die "Couldn't pop mark: $msg" unless $state;
     }
+    return;
 }
 sub RollbackDumpTo {
     my $self = shift;
@@ -798,6 +803,7 @@ sub RollbackDumpTo {
         my ($state, $msg) = $_->RollbackTo( @_ );
         die "Couldn't rollback to mark: $msg" unless $state;
     }
+    return;
 }
 }
 
diff --git a/lib/RT/Shredder/POD.pm b/lib/RT/Shredder/POD.pm
index ee4fb09..51b0669 100644
--- a/lib/RT/Shredder/POD.pm
+++ b/lib/RT/Shredder/POD.pm
@@ -59,6 +59,7 @@ sub plugin_html
     my $parser = RT::Shredder::POD::HTML->new;
     $parser->select('ARGUMENTS', 'USAGE');
     $parser->parse_from_file( $file, $out_fh );
+    return;
 }
 
 sub plugin_cli
@@ -69,6 +70,7 @@ sub plugin_cli
     $parser->select('SYNOPSIS', 'ARGUMENTS', 'USAGE');
     $parser->add_selection('NAME') unless $no_name;
     $parser->parse_from_file( $file, $out_fh );
+    return;
 }
 
 sub shredder_cli
@@ -78,6 +80,7 @@ sub shredder_cli
     my $parser = Pod::PlainText->new();
     $parser->select('NAME', 'SYNOPSIS', 'USAGE', 'OPTIONS');
     $parser->parse_from_file( $file, $out_fh );
+    return;
 }
 
 package RT::Shredder::POD::HTML;
@@ -97,6 +100,7 @@ sub command
     print $out_fh $expansion;
     print $out_fh "</$tag>" if $tag;
     print $out_fh "\n";
+    return;
 }
 
 sub verbatim
@@ -107,6 +111,7 @@ sub verbatim
     print $out_fh $paragraph;
     print $out_fh "</pre>";
     print $out_fh "\n";
+    return;
 }
 
 sub textblock {
@@ -118,6 +123,7 @@ sub textblock {
     print $out_fh $expansion;
     print $out_fh "</p>";
     print $out_fh "\n";
+    return;
 }
 
 sub interior_sequence {
diff --git a/lib/RT/Shredder/Plugin.pm b/lib/RT/Shredder/Plugin.pm
index d929eca..4227059 100644
--- a/lib/RT/Shredder/Plugin.pm
+++ b/lib/RT/Shredder/Plugin.pm
@@ -103,6 +103,7 @@ sub _Init
     my $self = shift;
     my %args = ( @_ );
     $self->{'opt'} = \%args;
+    return;
 }
 
 =head2 List
diff --git a/lib/RT/Shredder/Plugin/Base.pm b/lib/RT/Shredder/Plugin/Base.pm
index 7ada97e..de32517 100644
--- a/lib/RT/Shredder/Plugin/Base.pm
+++ b/lib/RT/Shredder/Plugin/Base.pm
@@ -61,14 +61,14 @@ sub new
 {
     my $proto = shift;
     my $self = bless( {}, ref $proto || $proto );
-    $self->_Init( @_ );
-    return $self;
+    return $self->_Init( @_ );
 }
 
 sub _Init
 {
     my $self = shift;
     $self->{'opt'} = { @_ };
+    return $self;
 }
 
 =head1 USAGE
@@ -125,8 +125,9 @@ sub HasSupportForArgs
     foreach my $a( @args ) {
         push @unsupported, $a unless grep $_ eq $a, $self->SupportArgs;
     }
-    return( 1 ) unless @unsupported;
-    return( 0, "Plugin doesn't support argument(s): @unsupported" ) if @unsupported;
+    return( 0, "Plugin doesn't support argument(s): @unsupported" )
+        if @unsupported;
+    return( 1 );
 }
 
 =head3 TestArgs
diff --git a/lib/RT/Shredder/Plugin/Summary.pm b/lib/RT/Shredder/Plugin/Summary.pm
index a81b1f0..e95a8eb 100644
--- a/lib/RT/Shredder/Plugin/Summary.pm
+++ b/lib/RT/Shredder/Plugin/Summary.pm
@@ -76,7 +76,6 @@ sub Run
     my $method = 'WriteDown'. $class;
     $method = 'WriteDownDefault' unless $self->can($method);
     return $self->$method( %args );
-    return 1;
 }
 
 my %skip_refs_to = ();

commit efdabcdb08f655c99bcf9d5f54c6a36c3ca7764a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sun Feb 6 04:43:54 2011 +0300

    update perl critic policies

diff --git a/.perlcriticrc b/.perlcriticrc
index 9cf8f63..1424630 100644
--- a/.perlcriticrc
+++ b/.perlcriticrc
@@ -4,3 +4,23 @@
 exclude = Subroutines::ProhibitExplicitReturnUndef  Modules::RequireFilenameMatchesPackage TestingAndDebugging::ProhibitNoStrict
 color = 1
 verbose = 7
+
+
+# we don't unpack @_ right away as we mostly use named vars with defaults:
+# sub foo {
+#     my $self = shift;
+#     my %args = ( default => 'value', ..., @_ );
+# ...
+[-Subroutines::RequireArgUnpacking]
+
+# Readonly superiority is not convincing, especially considering
+# that 'use constant' participates in constants folding during
+# compilation
+[-ValuesAndExpressions::ProhibitConstantPragma]
+
+# brutal
+[BuiltinFunctions::RequireBlockGrep]
+severity = 1
+
+[BuiltinFunctions::RequireBlockMap]
+severity = 1

-----------------------------------------------------------------------


More information about the rt-commit mailing list