4 use warnings FATAL => 'all';
6 use constant _PERL_LT_5_8_4 => ($] < 5.008004) ? 1 : 0;
8 our $VERSION = '1.002002'; # 1.2.2
12 last unless defined && !ref && int != 1;
13 die "Major version specified as $_ - this is strictures version 1";
15 # disable this since Foo->VERSION(undef) correctly returns the version
16 # and that can happen either if our caller passes undef explicitly or
17 # because the for above autovivified $_[1] - I could make it stop but
18 # it's pointless since we don't want to blow up if the caller does
19 # something valid either.
20 no warnings 'uninitialized';
21 shift->SUPER::VERSION(@_);
26 warnings->import(FATAL => 'all');
28 my $extra_tests = do {
29 if (exists $ENV{PERL_STRICTURES_EXTRA}) {
30 if (_PERL_LT_5_8_4 and $ENV{PERL_STRICTURES_EXTRA}) {
31 die 'PERL_STRICTUTRES_EXTRA checks are not available on perls older than 5.8.4, '
32 . "please unset \$ENV{PERL_STRICTURES_EXTRA}\n";
34 $ENV{PERL_STRICTURES_EXTRA};
35 } elsif (! _PERL_LT_5_8_4) {
36 !!($0 =~ /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
37 and (-e '.git' or -e '.svn'))
43 require multidimensional;
44 require bareword::filehandles;
47 indirect->unimport(':fatal');
48 multidimensional->unimport;
49 bareword::filehandles->unimport;
52 strictures.pm extra testing active but couldn't load modules.
53 Extra testing is auto-enabled in checkouts only, so if you're the author
54 of a strictures using module you need to run:
56 cpan indirect multidimensional bareword::filehandles
58 but these modules are not required by your users.
60 Error loading modules was: $@
71 strictures - turn on strict and make all warnings fatal
80 use warnings FATAL => 'all';
82 except when called from a file where $0 matches:
84 /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
86 and when either '.git' or '.svn' is present in the current directory (with
87 the intention of only forcing extra tests on the author side) - or when the
88 PERL_STRICTURES_EXTRA environment variable is set, in which case
95 use warnings FATAL => 'all';
98 no bareword::filehandles;
100 Note that _EXTRA may at some point add even more tests, with only a minor
101 version increase, but any changes to the effect of 'use strictures' in
102 normal mode will involve a major version bump.
104 Be aware: THIS MEANS THE EXTRA TEST MODULES ARE REQUIRED FOR AUTHORS OF
105 STRICTURES USING CODE - but not by end users thereof.
109 I've been writing the equivalent of this module at the top of my code for
110 about a year now. I figured it was time to make it shorter.
112 Things like the importer in 'use Moose' don't help me because they turn
113 warnings on but don't make them fatal - which from my point of view is
114 useless because I want an exception to tell me my code isn't warnings clean.
116 Any time I see a warning from my code, that indicates a mistake.
118 Any time my code encounters a mistake, I want a crash - not spew to STDERR
119 and then unknown (and probably undesired) subsequent behaviour.
121 I also want to ensure that obvious coding mistakes, like indirect object
122 syntax (and not so obvious mistakes that cause things to accidentally compile
123 as such) get caught, but not at the cost of an XS dependency and not at the
124 cost of blowing things up on another machine.
126 Therefore, strictures turns on indirect checking only when it thinks it's
127 running in a compilation (or pod coverage) test - though if this causes
128 undesired behaviour this can be overridden by setting the
129 PERL_STRICTURES_EXTRA environment variable.
131 If additional useful author side checks come to mind, I'll add them to the
132 _EXTRA code path only - this will result in a minor version increase (i.e.
133 1.000000 to 1.001000 (1.1.0) or similar). Any fixes only to the mechanism of
134 this code will result in a subversion increas (i.e. 1.000000 to 1.000001
137 If the behaviour of 'use strictures' in normal mode changes in any way, that
138 will constitute a major version increase - and the code already checks
139 when its version is tested to ensure that
143 will continue to only introduce the current set of strictures even if 2.0 is
150 This method does the setup work described above in L</DESCRIPTION>
154 This method traps the strictures->VERSION(1) call produced by a use line
155 with a version number on it and does the version check.
157 =head1 COMMUNITY AND SUPPORT
161 irc.perl.org #toolchain
163 (or bug 'mst' in query on there or freenode)
165 =head2 Git repository
167 Gitweb is on http://git.shadowcat.co.uk/ and the clone URL is:
169 git clone git://git.shadowcat.co.uk/p5sagit/strictures.git
173 mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
177 None required yet. Maybe this module is perfect (hahahahaha ...).
181 Copyright (c) 2010 the strictures L</AUTHOR> and L</CONTRIBUTORS>
186 This library is free software and may be distributed under the same terms