fix warnings, improve author side error
[p5sagit/strictures.git] / lib / strictures.pm
index 68ca44c..976ff13 100644 (file)
@@ -3,13 +3,19 @@ package strictures;
 use strict;
 use warnings FATAL => 'all';
 
-our $VERSION = '1.000000'; # 1.0.0
+our $VERSION = '1.001001'; # 1.1.1
 
 sub VERSION {
   for ($_[1]) {
     last unless defined && !ref && int != 1;
     die "Major version specified as $_ - this is strictures version 1";
   }
+  # disable this since Foo->VERSION(undef) correctly returns the version
+  # and that can happen either if our caller passes undef explicitly or
+  # because the for above autovivified $_[1] - I could make it stop but
+  # it's pointless since we don't want to blow up if the caller does
+  # something valid either.
+  no warnings 'uninitialized';
   shift->SUPER::VERSION(@_);
 }
 
@@ -20,14 +26,19 @@ sub import {
     if (exists $ENV{PERL_STRICTURES_EXTRA}) {
       $ENV{PERL_STRICTURES_EXTRA}
     } else {
-      !!($0 =~ /^x?t\/.*(?:load|compile|coverage).*\.t$/)
+      !!($0 =~ /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
+         and (-e '.git' or -e '.svn'))
     }
   };
   if ($do_indirect) {
     if (eval { require indirect; 1 }) {
       indirect->unimport(':fatal');
     } else {
-      die "strictures.pm extra testing active but couldn't load indirect.pm: $@";
+      die "strictures.pm extra testing active but couldn't load indirect.pm
+Extra testing is auto-enabled in checkouts only, so if you're the author
+of a strictures using module you should 'cpan indirect' but the module
+is not required by your users.
+Error loading indirect.pm was: $@";
     }
   }
 }
@@ -50,10 +61,11 @@ is equivalent to
 
 except when called from a file where $0 matches:
 
-  /^x?t\/.*(?:load|compile|coverage).*\.t$/
+  /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
 
-or when the PERL_STRICTURES_EXTRA environment variable is set, in which
-case
+and when either '.git' or '.svn' is present in the current directory (with
+the intention of only forcing extra tests on the author side) - or when the
+PERL_STRICTURES_EXTRA environment variable is set, in which case
 
   use strictures 1;
 
@@ -67,6 +79,9 @@ Note that _EXTRA may at some point add even more tests, with only a minor
 version increase, but any changes to the effect of 'use strictures' in
 normal mode will involve a major version bump.
 
+Be aware: THIS MEANS INDIRECT IS REQUIRED FOR AUTHORS OF STRICTURES USING
+CODE - but not by end users thereof.
+
 =head1 DESCRIPTION
 
 I've been writing the equivalent of this module at the top of my code for