4 use warnings FATAL => 'all';
6 our $VERSION = '1.002001'; # 1.2.1
10 last unless defined && !ref && int != 1;
11 die "Major version specified as $_ - this is strictures version 1";
13 # disable this since Foo->VERSION(undef) correctly returns the version
14 # and that can happen either if our caller passes undef explicitly or
15 # because the for above autovivified $_[1] - I could make it stop but
16 # it's pointless since we don't want to blow up if the caller does
17 # something valid either.
18 no warnings 'uninitialized';
19 shift->SUPER::VERSION(@_);
24 warnings->import(FATAL => 'all');
25 my $extra_tests = do {
26 if (exists $ENV{PERL_STRICTURES_EXTRA}) {
27 $ENV{PERL_STRICTURES_EXTRA}
29 !!($0 =~ /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
30 and (-e '.git' or -e '.svn'))
36 require multidimensional;
37 require bareword::filehandles;
40 indirect->unimport(':fatal');
41 multidimensional->unimport;
42 bareword::filehandles->unimport;
44 die "strictures.pm extra testing active but couldn't load modules.
45 Extra testing is auto-enabled in checkouts only, so if you're the author
46 of a strictures using module you need to run:
48 cpan indirect multidimensional bareword::filehandles
50 but these modules are not required by your users.
52 Error loading modules was: $@";
62 strictures - turn on strict and make all warnings fatal
71 use warnings FATAL => 'all';
73 except when called from a file where $0 matches:
75 /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
77 and when either '.git' or '.svn' is present in the current directory (with
78 the intention of only forcing extra tests on the author side) - or when the
79 PERL_STRICTURES_EXTRA environment variable is set, in which case
86 use warnings FATAL => 'all';
89 no bareword::filehandles;
91 Note that _EXTRA may at some point add even more tests, with only a minor
92 version increase, but any changes to the effect of 'use strictures' in
93 normal mode will involve a major version bump.
95 Be aware: THIS MEANS THE EXTRA TEST MODULES ARE REQUIRED FOR AUTHORS OF
96 STRICTURES USING CODE - but not by end users thereof.
100 I've been writing the equivalent of this module at the top of my code for
101 about a year now. I figured it was time to make it shorter.
103 Things like the importer in 'use Moose' don't help me because they turn
104 warnings on but don't make them fatal - which from my point of view is
105 useless because I want an exception to tell me my code isn't warnings clean.
107 Any time I see a warning from my code, that indicates a mistake.
109 Any time my code encounters a mistake, I want a crash - not spew to STDERR
110 and then unknown (and probably undesired) subsequent behaviour.
112 I also want to ensure that obvious coding mistakes, like indirect object
113 syntax (and not so obvious mistakes that cause things to accidentally compile
114 as such) get caught, but not at the cost of an XS dependency and not at the
115 cost of blowing things up on another machine.
117 Therefore, strictures turns on indirect checking only when it thinks it's
118 running in a compilation (or pod coverage) test - though if this causes
119 undesired behaviour this can be overriden by setting the
120 PERL_STRICTURES_EXTRA environment variable.
122 If additional useful author side checks come to mind, I'll add them to the
123 _EXTRA code path only - this will result in a minor version increase (i.e.
124 1.000000 to 1.001000 (1.1.0) or similar). Any fixes only to the mechanism of
125 this code will result in a subversion increas (i.e. 1.000000 to 1.000001
128 If the behaviour of 'use strictures' in normal mode changes in any way, that
129 will constitute a major version increase - and the code already checks
130 when its version is tested to ensure that
134 will continue to only introduce the current set of strictures even if 2.0 is
141 This method does the setup work described above in L</DESCRIPTION>
145 This method traps the strictures->VERSION(1) call produced by a use line
146 with a version number on it and does the version check.
148 =head1 COMMUNITY AND SUPPORT
152 irc.perl.org #toolchain
154 (or bug 'mst' in query on there or freenode)
156 =head2 Git repository
158 Gitweb is on http://git.shadowcat.co.uk/ and the clone URL is:
160 git clone git://git.shadowcat.co.uk/p5sagit/strictures.git
164 mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
168 None required yet. Maybe this module is perfect (hahahahaha ...).
172 Copyright (c) 2010 the strictures L</AUTHOR> and L</CONTRIBUTORS>
177 This library is free software and may be distributed under the same terms