[Rt-commit] rt branch, 3.8/perlcritic, updated. rt-3.8.9-25-g695d1ac

Alex Vandiver alexmv at bestpractical.com
Thu Mar 3 17:01:03 EST 2011


The branch, 3.8/perlcritic has been updated
       via  695d1acb59e44938ac9e18bf14a11886cfa03993 (commit)
      from  f7352fdfb256e048289c2a33662de5cd09cbfb42 (commit)

Summary of changes:
 lib/RT/Shredder/Plugin.pm |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 695d1acb59e44938ac9e18bf14a11886cfa03993
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Mar 3 16:51:05 2011 -0500

    Replace 3384147 with a less error-prone explicit loop
    
    An else-less 'if' inside a map produces the single value '' when the
    if is false (the return value of the test).  In this context, this
    would likely lead to an odd number of elements in the hashref, instead
    of the pre-3384147 result of simply having a '' key.  Additionally,
    perlcritic warns (not incorrectly) about the construct.
    
    Replace the map with an explicit for loop, which makes perlcritic
    happy, in addition to solving the "odd number of elements" bug above.

diff --git a/lib/RT/Shredder/Plugin.pm b/lib/RT/Shredder/Plugin.pm
index 61e1a43..b7c63ec 100644
--- a/lib/RT/Shredder/Plugin.pm
+++ b/lib/RT/Shredder/Plugin.pm
@@ -127,7 +127,10 @@ sub List
         push @files, glob $mask;
     }
 
-    my %res = map { if ( $_ =~ m/([^\\\/]+)\.pm$/) { $1 => $_ } } reverse @files;
+    my %res;
+    for my $f (reverse @files) {
+        $res{$1} = $_ if $f =~ /([^\\\/]+)\.pm$/;
+    }
 
     return %res unless $type;
 

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


More information about the Rt-commit mailing list