[Rt-commit] rt branch, 4.2/shredder-critic, created. rt-4.0.0rc4-85-ga6dff98
Ruslan Zakirov
ruz at bestpractical.com
Sat Feb 5 20:47:07 EST 2011
The branch, 4.2/shredder-critic has been created
at a6dff987c47ba2cda1257042b8e38e78440af708 (commit)
- Log -----------------------------------------------------------------
commit b2cbc2b67d0f858dd01f2c43202ca76df120ae3c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Feb 5 04:49:48 2011 +0300
sort is undefined in scalar context
diff --git a/lib/RT/Shredder/Plugin/Base/Search.pm b/lib/RT/Shredder/Plugin/Base/Search.pm
index 4e092b2..4c1d550 100644
--- a/lib/RT/Shredder/Plugin/Base/Search.pm
+++ b/lib/RT/Shredder/Plugin/Base/Search.pm
@@ -76,10 +76,9 @@ Allow you to limit search results. B<< Default value is C<10> >>.
sub SupportArgs
{
my %seen;
- return sort
- grep $_ && !$seen{$_},
- shift->SUPER::SupportArgs(@_),
- qw(limit);
+ my @res = sort grep defined && length && !$seen{$_}++,
+ shift->SUPER::SupportArgs(@_), qw(limit);
+ return @res;
}
sub TestArgs
commit 180dd02e8e2390802914ed0f89b2d61604b8409f
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Feb 5 04:50:32 2011 +0300
use foreach to edit array, not map
diff --git a/lib/RT/Shredder/Plugin/Attachments.pm b/lib/RT/Shredder/Plugin/Attachments.pm
index d55aaee..2cbd207 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;
+ $_ = "RT::Attachment-$_" foreach @objs;
return (1, @objs);
}
commit 0a8e675936a01a22b8e50d47ba066e9ae396c873
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sun Feb 6 03:08:41 2011 +0300
eval_require util function that does eval "require $class"
diff --git a/lib/RT/Util.pm b/lib/RT/Util.pm
index f8b878a..7ec15dc 100644
--- a/lib/RT/Util.pm
+++ b/lib/RT/Util.pm
@@ -52,7 +52,7 @@ use warnings;
use base 'Exporter';
-our @EXPORT = qw/safe_run_child/;
+our @EXPORT_OK = qw/safe_run_child eval_require/;
sub safe_run_child (&) {
my $our_pid = $$;
@@ -96,6 +96,29 @@ sub safe_run_child (&) {
return $want? (@res) : $res[0];
}
+sub eval_require ($;$) {
+ my $class = shift;
+ my $fatal = shift;
+
+ local $@;
+ return 1 if eval "require $class; 1";
+
+ if ( $fatal ) {
+ return $fatal->() if ref $fatal eq 'CODE';
+
+ require Carp;
+ return Carp::croak($@);
+ }
+
+ (my $filename = $class) =~ s{::}{/}g;
+ if ( rindex( $@, "Can't locate $filename", 0 ) != 0 ) { # doesn't start with
+ require Carp;
+ return Carp::carp($@);
+ }
+ return 0;
+}
+
+use RT::Base;
RT::Base->_ImportOverlays();
1;
commit e8a349f96366d8b3fcac7161291f30f35fcbe0cb
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sun Feb 6 03:09:08 2011 +0300
use eval_require
diff --git a/lib/RT.pm b/lib/RT.pm
index 865bc02..8a754ba 100644
--- a/lib/RT.pm
+++ b/lib/RT.pm
@@ -54,6 +54,7 @@ package RT;
use File::Spec ();
use Cwd ();
+use RT::Util qw(eval_require);
use vars qw($Config $System $SystemUser $Nobody $Handle $Logger $_Privileged $_Unprivileged $_INSTALL_MODE);
@@ -457,11 +458,10 @@ sub InitClasses {
}
foreach my $class ( grep $_, RT->Config->Get('CustomFieldValuesSources') ) {
- local $@;
- eval "require $class; 1" or $RT::Logger->error(
+ eval_require $class, sub { $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 cf24a02..9080ca0 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -53,6 +53,7 @@ use warnings;
use File::Spec ();
use Symbol::Global::Name;
+use RT::Util qw(eval_require);
=head1 NAME
@@ -479,10 +480,9 @@ our %META = (
my $self = shift;
my $value = shift;
return if $value;
- return if $INC{'GraphViz.pm'};
- local $@;
- return if eval {require GraphViz; 1};
- $RT::Logger->debug("You've enabled GraphViz, but we couldn't load the module: $@");
+ return if eval_require 'GraphViz' => sub {
+ $RT::Logger->debug("You've enabled GraphViz, but we couldn't load the module: $@");
+ };
$self->Set( DisableGraphViz => 1 );
},
},
@@ -492,10 +492,9 @@ our %META = (
my $self = shift;
my $value = shift;
return if $value;
- return if $INC{'GD.pm'};
- local $@;
- return if eval {require GD; 1};
- $RT::Logger->debug("You've enabled GD, but we couldn't load the module: $@");
+ return if eval_require 'GD' => sub {
+ $RT::Logger->debug("You've enabled GD, but we couldn't load the module: $@");
+ };
$self->Set( DisableGD => 1 );
},
},
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index 890da04..068a2c1 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -61,6 +61,7 @@ sub Table {'CustomFields'}
use RT::CustomFieldValues;
use RT::ObjectCustomFields;
use RT::ObjectCustomFieldValues;
+use RT::Util qw(eval_require);
our %FieldTypes = (
Select => {
@@ -518,7 +519,7 @@ sub Values {
my $class = $self->ValuesClass;
if ( $class ne 'RT::CustomFieldValues') {
- eval "require $class" or die "$@";
+ eval_require $class, 'fatal';
}
my $cf_values = $class->new( $self->CurrentUser );
# if the user has no rights, return an empty object
diff --git a/lib/RT/I18N.pm b/lib/RT/I18N.pm
index fd8ef11..cc656cd 100644
--- a/lib/RT/I18N.pm
+++ b/lib/RT/I18N.pm
@@ -461,8 +461,9 @@ 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 RT::Util qw(eval_require);
+use constant HAS_ENCODE_GUESS => eval_require 'Encode::Guess';
+use constant HAS_ENCODE_DETECT => eval_require 'Encode::Detect::Detector';
sub _GuessCharset {
my $fallback = _CanonicalizeCharset('iso-8859-1');
diff --git a/lib/RT/Interface/Web/Session.pm b/lib/RT/Interface/Web/Session.pm
index 008e6df..02dc81e 100644
--- a/lib/RT/Interface/Web/Session.pm
+++ b/lib/RT/Interface/Web/Session.pm
@@ -51,6 +51,7 @@ use warnings;
use strict;
use RT::CurrentUser;
+use RT::Util qw(eval_require);
=head1 NAME
@@ -84,8 +85,7 @@ sub Class {
my $class = RT->Config->Get('WebSessionClass')
|| $self->Backends->{RT->Config->Get('DatabaseType')}
|| 'Apache::Session::File';
- eval "require $class";
- die $@ if $@;
+ eval_require $class => 'fatal';
return $class;
}
diff --git a/lib/RT/SQL.pm b/lib/RT/SQL.pm
index 4f2c00d..55312e4 100644
--- a/lib/RT/SQL.pm
+++ b/lib/RT/SQL.pm
@@ -51,11 +51,8 @@ package RT::SQL;
use strict;
use warnings;
-
-use constant HAS_BOOLEAN_PARSER => do {
- local $@;
- eval { require Parse::BooleanLogic; 1 }
-};
+use RT::Util qw(eval_require);
+use constant HAS_BOOLEAN_PARSER => eval_require 'Parse::BooleanLogic';
# States
use constant VALUE => 1;
diff --git a/lib/RT/ScripAction.pm b/lib/RT/ScripAction.pm
index 6b4ba6e..1d90d1d 100644
--- a/lib/RT/ScripAction.pm
+++ b/lib/RT/ScripAction.pm
@@ -74,6 +74,8 @@ use warnings;
use base 'RT::Record';
+use RT::Util qw(eval_require);
+
sub Table {'ScripActions'}
@@ -170,8 +172,8 @@ sub LoadAction {
my $module = $1;
my $type = "RT::Action::". $module;
- eval "require $type" || die "Require of $type failed.\n$@\n";
-
+ eval_require $type => sub { die "Require of $type action module failed.\n$@\n" };
+
$self->{'Action'} = $type->new ( Argument => $self->Argument,
CurrentUser => $self->CurrentUser,
ScripActionObj => $self,
diff --git a/lib/RT/ScripCondition.pm b/lib/RT/ScripCondition.pm
index 17c3cbe..d039430 100644
--- a/lib/RT/ScripCondition.pm
+++ b/lib/RT/ScripCondition.pm
@@ -75,6 +75,8 @@ use warnings;
use base 'RT::Record';
+use RT::Util qw(eval_require);
+
sub Table {'ScripConditions'}
@@ -168,7 +170,7 @@ sub LoadCondition {
my $module = $1;
my $type = "RT::Condition::". $module;
- eval "require $type" || die "Require of $type failed.\n$@\n";
+ eval_require $type => sub { 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 d007a35..dcf8991 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -51,6 +51,7 @@ package RT::Shredder;
use strict;
use warnings;
+use RT::Util qw(eval_require);
=head1 NAME
@@ -349,8 +350,7 @@ sub CastObjectsToRecords
$targets = $$targets if ref $targets;
my ($class, $id) = split /-/, $targets;
$class = 'RT::'. $class unless $class =~ /^RTx?::/i;
- eval "require $class";
- die "Couldn't load '$class' module" if $@;
+ eval_require $class, 'fatal';
my $obj = $class->new( RT->SystemUser );
die "Couldn't construct new '$class' object" unless $obj;
$obj->Load( $id );
diff --git a/lib/RT/Shredder/ACE.pm b/lib/RT/Shredder/ACE.pm
index 702df8c..fe0b348 100644
--- a/lib/RT/Shredder/ACE.pm
+++ b/lib/RT/Shredder/ACE.pm
@@ -46,7 +46,7 @@
#
# END BPS TAGGED BLOCK }}}
-use RT::ACE ();
+use RT::ACE qw();
package RT::ACE;
use strict;
diff --git a/lib/RT/Shredder/Plugin.pm b/lib/RT/Shredder/Plugin.pm
index fdc2103..570b240 100644
--- a/lib/RT/Shredder/Plugin.pm
+++ b/lib/RT/Shredder/Plugin.pm
@@ -51,6 +51,7 @@ package RT::Shredder::Plugin;
use strict;
use warnings FATAL => 'all';
use File::Spec ();
+use RT::Util qw(eval_require);
=head1 NAME
@@ -134,7 +135,7 @@ sub List
delete $res{'Base'};
foreach my $name( keys %res ) {
my $class = join '::', qw(RT Shredder Plugin), $name;
- unless( eval "require $class" ) {
+ unless( eval_require $class ) {
delete $res{ $name };
next;
}
@@ -165,9 +166,8 @@ sub LoadByName
my $self = shift;
my $name = shift or return (0, "Name not specified");
- local $@;
my $plugin = "RT::Shredder::Plugin::$name";
- eval "require $plugin" or return( 0, $@ );
+ eval_require $plugin or return( 0, "Failed to load $plugin" );
return( 0, "Plugin '$plugin' has no method new") unless $plugin->can('new');
my $obj = eval { $plugin->new( @_ ) };
diff --git a/lib/RT/Squish/JS.pm b/lib/RT/Squish/JS.pm
index 8b78e70..0e73a57 100644
--- a/lib/RT/Squish/JS.pm
+++ b/lib/RT/Squish/JS.pm
@@ -65,6 +65,9 @@ use warnings;
package RT::Squish::JS;
use base 'RT::Squish';
+use RT::Util qw(eval_require);
+use constant HAS_JS_MINIFIER => eval_require 'JavaScript::Minifier';
+
=head2 Squish
not only concatenate files, but also minify them
@@ -104,14 +107,8 @@ sub Filter {
}
}
- unless ($minified) {
- eval { require JavaScript::Minifier };
- if ($@) {
- $RT::Logger->debug("can't load JavaScript::Minifier: $@");
- }
- else {
- $content = JavaScript::Minifier::minify( input => $content );
- }
+ if ( !$minified && HAS_JS_MINIFIER ) {
+ $content = JavaScript::Minifier::minify( input => $content );
}
return $content;
}
diff --git a/lib/RT/Test/GnuPG.pm b/lib/RT/Test/GnuPG.pm
index 206c06d..ee62a32 100644
--- a/lib/RT/Test/GnuPG.pm
+++ b/lib/RT/Test/GnuPG.pm
@@ -4,6 +4,7 @@ use Test::More;
use base qw(RT::Test);
use File::Temp qw(tempdir);
use RT::Crypt::GnuPG;
+use RT::Util qw(eval_require);
our @EXPORT =
qw(create_a_ticket update_ticket cleanup_headers set_queue_crypt_options
@@ -17,7 +18,7 @@ sub import {
my $t = $class->builder;
$t->plan( skip_all => 'GnuPG required.' )
- unless eval { require GnuPG::Interface; 1 };
+ unless eval_require 'GnuPG::Interface';
$t->plan( skip_all => 'gpg executable is required.' )
unless RT::Test->find_executable('gpg');
commit ce91c2cf0b16ed8f7ac182308fca69ad90171f58
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sun Feb 6 04:03:26 2011 +0300
use warnings, run code after package definition
diff --git a/lib/RT/Shredder/ACE.pm b/lib/RT/Shredder/ACE.pm
index fe0b348..9102e89 100644
--- a/lib/RT/Shredder/ACE.pm
+++ b/lib/RT/Shredder/ACE.pm
@@ -46,8 +46,8 @@
#
# END BPS TAGGED BLOCK }}}
-use RT::ACE qw();
package RT::ACE;
+use RT::ACE qw();
use strict;
use warnings;
diff --git a/lib/RT/Shredder/Attachment.pm b/lib/RT/Shredder/Attachment.pm
index d4f44d5..500e493 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 38a4558..fea4a44 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 6f92c16..10bc0d4 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 d46a0a4..29cd5ae 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/Dependencies.pm b/lib/RT/Shredder/Dependencies.pm
index 09a3846..2906ded 100644
--- a/lib/RT/Shredder/Dependencies.pm
+++ b/lib/RT/Shredder/Dependencies.pm
@@ -49,6 +49,8 @@
package RT::Shredder::Dependencies;
use strict;
+use warnings;
+
use RT::Shredder::Exceptions;
use RT::Shredder::Constants;
use RT::Shredder::Dependency;
diff --git a/lib/RT/Shredder/Dependency.pm b/lib/RT/Shredder/Dependency.pm
index 14556e4..011b653 100644
--- a/lib/RT/Shredder/Dependency.pm
+++ b/lib/RT/Shredder/Dependency.pm
@@ -49,6 +49,8 @@
package RT::Shredder::Dependency;
use strict;
+use warnings;
+
use RT::Shredder::Constants;
use RT::Shredder::Exceptions;
diff --git a/lib/RT/Shredder/Group.pm b/lib/RT/Shredder/Group.pm
index 1b0a743..629e4e1 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 ef5e5a4..838931d 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 1b5bf11..9cfed85 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 be4b851..938c5dd 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 83c091f..4383208 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 81ed3ff..239e46c 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 cef555d..6d72076 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 11320f7..36bd409 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 44c4850..3df6bb7 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 73dfc42..2455f46 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 a7f6969..6e9eff8 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 570e948..5def746 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 3dec80f..cec4dfa 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 6f26a20..35c6c46 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 177ee05d7b2fa203b8f8ad92f8f2ab943d5c070e
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 dcf8991..b2d3976 100644
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@ -272,6 +272,7 @@ sub Init
%opt = @_;
RT::LoadConfig();
RT::Init();
+ return;
}
=head4 new
@@ -288,8 +289,7 @@ sub new
{
my $proto = shift;
my $self = bless( {}, ref $proto || $proto );
- $self->_Init( @_ );
- return $self;
+ return $self->_Init( @_ );
}
sub _Init
@@ -299,6 +299,7 @@ sub _Init
$self->{'cache'} = {};
$self->{'resolver'} = {};
$self->{'dump_plugins'} = [];
+ return $self;
}
=head4 CastObjectsToRecords( Objects => undef )
@@ -538,6 +539,7 @@ sub WipeoutAll
next if $v->{'State'} & (WIPED | IN_WIPING);
$self->Wipeout( Object => $v->{'Object'} );
}
+ return;
}
sub Wipeout
@@ -557,6 +559,7 @@ sub Wipeout
die $@ if RT::Shredder::Exception::Info->caught;
die "Couldn't wipeout object: $@";
}
+ return;
}
sub _Wipeout
@@ -614,6 +617,7 @@ sub ValidateRelations
next if( $record->{'State'} & VALID );
$record->{'Object'}->ValidateRelations( Shredder => $self );
}
+ return;
}
=head3 Data storage and backups
@@ -765,6 +769,7 @@ sub DumpObject {
my ($state, $msg) = $_->Run( %args );
die "Couldn't run plugin: $msg" unless $state;
}
+ return;
}
{ my $mark = 1; # XXX: integer overflows?
@@ -780,9 +785,10 @@ sub PushDumpMark {
sub PopDumpMark {
my $self = shift;
foreach (@{ $self->{'dump_plugins'} }) {
- my ($state, $msg) = $_->PushMark( @_ );
+ my ($state, $msg) = $_->PopMark( @_ );
die "Couldn't pop mark: $msg" unless $state;
}
+ return;
}
sub RollbackDumpTo {
my $self = shift;
@@ -790,6 +796,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 f21efdc..35ae0a0 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 570b240..89870d1 100644
--- a/lib/RT/Shredder/Plugin.pm
+++ b/lib/RT/Shredder/Plugin.pm
@@ -104,6 +104,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 086908d..2ca04f4 100644
--- a/lib/RT/Shredder/Plugin/Base.pm
+++ b/lib/RT/Shredder/Plugin/Base.pm
@@ -69,6 +69,7 @@ sub _Init
{
my $self = shift;
$self->{'opt'} = { @_ };
+ return $self;
}
=head1 USAGE
@@ -125,8 +126,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 c40d99b..67e32af 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 a6dff987c47ba2cda1257042b8e38e78440af708
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