4 use warnings FATAL => 'all';
6 our $VERSION = '1.001000'; # 1.1.0
10 last unless defined && !ref && int != 1;
11 die "Major version specified as $_ - this is strictures version 1";
13 shift->SUPER::VERSION(@_);
18 warnings->import(FATAL => 'all');
19 my $do_indirect = do {
20 if (exists $ENV{PERL_STRICTURES_EXTRA}) {
21 $ENV{PERL_STRICTURES_EXTRA}
23 !!($0 =~ /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
24 and (-e '.git' or -e '.svn'))
28 if (eval { require indirect; 1 }) {
29 indirect->unimport(':fatal');
31 die "strictures.pm extra testing active but couldn't load indirect.pm: $@";
41 strictures - turn on strict and make all warnings fatal
50 use warnings FATAL => 'all';
52 except when called from a file where $0 matches:
54 /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
56 and when either '.git' or '.svn' is present in the current directory (with
57 the intention of only forcing extra tests on the author side) - or when the
58 PERL_STRICTURES_EXTRA environment variable is set, in which case
65 use warnings FATAL => 'all';
68 Note that _EXTRA may at some point add even more tests, with only a minor
69 version increase, but any changes to the effect of 'use strictures' in
70 normal mode will involve a major version bump.
74 I've been writing the equivalent of this module at the top of my code for
75 about a year now. I figured it was time to make it shorter.
77 Things like the importer in 'use Moose' don't help me because they turn
78 warnings on but don't make them fatal - which from my point of view is
79 useless because I want an exception to tell me my code isn't warnings clean.
81 Any time I see a warning from my code, that indicates a mistake.
83 Any time my code encounters a mistake, I want a crash - not spew to STDERR
84 and then unknown (and probably undesired) subsequent behaviour.
86 I also want to ensure that obvious coding mistakes, like indirect object
87 syntax (and not so obvious mistakes that cause things to accidentally compile
88 as such) get caught, but not at the cost of an XS dependency and not at the
89 cost of blowing things up on another machine.
91 Therefore, strictures turns on indirect checking only when it thinks it's
92 running in a compilation (or pod coverage) test - though if this causes
93 undesired behaviour this can be overriden by setting the
94 PERL_STRICTURES_EXTRA environment variable.
96 If additional useful author side checks come to mind, I'll add them to the
97 _EXTRA code path only - this will result in a minor version increase (i.e.
98 1.000000 to 1.001000 (1.1.0) or similar). Any fixes only to the mechanism of
99 this code will result in a subversion increas (i.e. 1.000000 to 1.000001
102 If the behaviour of 'use strictures' in normal mode changes in any way, that
103 will constitute a major version increase - and the code already checks
104 when its version is tested to ensure that
108 will continue to only introduce the current set of strictures even if 2.0 is
115 This method does the setup work described above in L</DESCRIPTION>
119 This method traps the strictures->VERSION(1) call produced by a use line
120 with a version number on it and does the version check.
122 =head1 COMMUNITY AND SUPPORT
126 irc.perl.org #toolchain
128 (or bug 'mst' in query on there or freenode)
130 =head2 Git repository
132 Gitweb is on http://git.shadowcat.co.uk/ and the clone URL is:
134 git clone git://git.shadowcat.co.uk/p5sagit/strictures.git
138 Matt S. Trout <mst@shadowcat.co.uk>
142 None required yet. Maybe this module is perfect (hahahahaha ...).
146 Copyright (c) 2010 the strictures L</AUTHOR> and L</CONTRIBUTORS>
151 This library is free software and may be distributed under the same terms