about summary refs log tree commit
diff options
context:
space:
mode:
authorSteve Hay <steve.m.hay@googlemail.com>2014-06-21 21:45:34 +0100
committerSteve Hay <steve.m.hay@googlemail.com>2014-06-21 21:45:34 +0100
commit4f43a25d533a2baa41bfaf0209f1831ba8ef210d (patch)
tree9f3012199d772d48661f30f09805bcc9bbf98d78
parentffb1a81f4048faa93a7896fe8d1c7bf4b793fc2a (diff)
downloadperl-libnet-4f43a25d533a2baa41bfaf0209f1831ba8ef210d.tar.gz
Test all files, not just files in blib/, with Perl::Critic
-rwxr-xr-xConfigure11
-rw-r--r--Makefile.PL2
-rw-r--r--demos/nntp.mirror13
-rwxr-xr-xdemos/smtp.self2
-rw-r--r--t/critic.t2
5 files changed, 17 insertions, 13 deletions
diff --git a/Configure b/Configure
index 9d0e0c8..c207277 100755
--- a/Configure
+++ b/Configure
@@ -11,6 +11,8 @@ use ExtUtils::MakeMaker qw(prompt);
 use Getopt::Std;
 use IO::File;
 
+## no critic (Subroutines::ProhibitSubroutinePrototypes)
+
 our($opt_d, $opt_o);
 
 ##
@@ -41,10 +43,9 @@ sub test_hostnames (\@)
 {
  my $hlist = shift;
  my @h = ();
- my $host;
  my $err = 0;
 
- foreach $host (@$hlist)
+ foreach my $host (@$hlist)
   {
    if(valid_host($host))
     {
@@ -217,10 +218,9 @@ MASK:
 
 sub default_hostname
 {
- my $host;
  my @host;
 
- foreach $host (@_)
+ foreach my $host (@_)
   {
    if(defined($host) && valid_host($host))
     {
@@ -577,8 +577,7 @@ print "Writing $libnet_cfg\n";
 
 print $fh "{\n";
 
-my $key;
-foreach $key (keys %cfg) {
+foreach my $key (keys %cfg) {
     my $val = $cfg{$key};
     if(!defined($val)) {
         $val = "undef";
diff --git a/Makefile.PL b/Makefile.PL
index 8bb6bb4..39d87be 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -23,6 +23,8 @@ use warnings;
 use ExtUtils::MakeMaker 6.64;
 use ExtUtils::MakeMaker qw(WriteMakefile);
 
+## no critic (Subroutines::ProhibitSubroutinePrototypes)
+
 sub running_under_cpan();
 
 #===============================================================================
diff --git a/demos/nntp.mirror b/demos/nntp.mirror
index 0976a38..6e80903 100644
--- a/demos/nntp.mirror
+++ b/demos/nntp.mirror
@@ -35,14 +35,16 @@ chdir($BaseDir) or die "Could not cd to $BaseDir\n";
 # expirationdays is the number of days to leave the articles around;
 #    set it to 0 if you want the articles to stay forever
 # If the groupname starts with a #, it is skipped
-open(GROUPLIST, 'grouplist.txt') or die "Could not open grouplist.txt\n";
+my $GroupList;
+open($GroupList, '<', 'grouplist.txt') or die "Could not open grouplist.txt\n";
 my @Groups;
-while(<GROUPLIST>) {
+while(<$GroupList>) {
         my $Line = $_; chomp($Line);
         if($Line eq '') { next };  # Skip blank lines
         if(substr($Line, 0, 1) eq '#') { next };  # Skip comments
         push(@Groups, $Line)
 }
+close $GroupList;
 
 my $NntpPtr = Net::NNTP->new('news.server.com');
 
@@ -57,7 +59,7 @@ foreach my $GroupLine (@Groups) {
         }
         chdir("$BaseDir/$GroupName") or die "Couldn't chdir to $GroupName\n";
         # Find the last article in the directory
-        my @AllInDir = <*>; my @RevSortedAllInDir = reverse(sort(@AllInDir));
+        my @AllInDir = glob('*'); my @RevSortedAllInDir = reverse(sort(@AllInDir));
         my $LenArr = @RevSortedAllInDir;
         my $NumLastInDir;
         if($LenArr > 0) { $NumLastInDir = $RevSortedAllInDir[0] }
@@ -79,9 +81,10 @@ foreach my $GroupLine (@Groups) {
                 my $ArtRef = $NntpPtr->article($GetArtNum);
                 my @ArtArr = @$ArtRef; my $ArtArrLen = @ArtArr;
                 if($ArtArrLen > 0 ) {  # Skip article numbers that had 0 len
-                        open(OUT, ">$GetArtNum") or
+                        my $Out;
+                        open($Out, '>', $GetArtNum) or
                                 die "Could not create $GroupName/$GetArtNum\n";
-                        print OUT @$ArtRef; close(OUT);
+                        print $Out @$ArtRef; close($Out);
                 }
 
                 # Check if we're at the end
diff --git a/demos/smtp.self b/demos/smtp.self
index 10200ea..8a87274 100755
--- a/demos/smtp.self
+++ b/demos/smtp.self
@@ -65,7 +65,7 @@ if($smtp->mail($user) && $smtp->to($user))
   $smtp->data();
 
   my @data;
-  map { s/-USER-/$user/g } @data=<DATA>;
+  map { s/-USER-/$user/g } @data=<DATA>; ## no critic (ControlStructures::ProhibitMutatingListFunctions)
 
   $smtp->datasend(@data);
   $smtp->dataend;
diff --git a/t/critic.t b/t/critic.t
index 33fe49f..5fe75e1 100644
--- a/t/critic.t
+++ b/t/critic.t
@@ -37,7 +37,7 @@ MAIN: {
         plan skip_all => 'Test::Perl::Critic required to test with Perl::Critic';
     }
     else {
-        all_critic_ok();
+        all_critic_ok('.');
     }
 }