strictures
view release on metacpan or search on metacpan
NAME
strictures - Turn on strict and make most warnings fatal
SYNOPSIS
use strictures 2;
is equivalent to
use strict;
use warnings FATAL => 'all';
use warnings NONFATAL => qw(
exec
recursion
internal
malloc
newline
experimental
deprecated
portable
);
no warnings 'once';
except when called from a file which matches:
(caller)[1] =~ /^(?:t|xt|lib|blib)[\\\/]/
and when either ".git", ".svn", ".hg", or ".bzr" is present in the
current directory (with the intention of only forcing extra tests on the
author side) -- or when ".git", ".svn", ".hg", or ".bzr" is present two
directories up along with "dist.ini" (which would indicate we are in a
"dzil test" operation, via Dist::Zilla) -- or when the
"PERL_STRICTURES_EXTRA" environment variable is set, in which case it
also does the equivalent of
no indirect 'fatal';
no multidimensional;
no bareword::filehandles;
Note that "PERL_STRICTURES_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.
If any of the extra testing modules are not present, strictures will
complain loudly, once, via "warn()", and then shut up. But you really
should consider installing them, they're all great anti-footgun tools.
DESCRIPTION
I've been writing the equivalent of this module at the top of my code
for about a year now. I figured it was time to make it shorter.
Things like the importer in "use Moose" don't help me because they turn
warnings on but don't make them fatal -- which from my point of view is
useless because I want an exception to tell me my code isn't
warnings-clean.
Any time I see a warning from my code, that indicates a mistake.
Any time my code encounters a mistake, I want a crash -- not spew to
STDERR and then unknown (and probably undesired) subsequent behaviour.
I also want to ensure that obvious coding mistakes, like indirect object
syntax (and not so obvious mistakes that cause things to accidentally
compile as such) get caught, but not at the cost of an XS dependency and
not at the cost of blowing things up on another machine.
Therefore, strictures turns on additional checking, but only when it
thinks it's running in a test file in a VCS checkout -- although if this
causes undesired behaviour this can be overridden by setting the
"PERL_STRICTURES_EXTRA" environment variable.
If additional useful author side checks come to mind, I'll add them to
the "PERL_STRICTURES_EXTRA" code path only -- this will result in a
minor version increase (e.g. 1.000000 to 1.001000 (1.1.0) or similar).
Any fixes only to the mechanism of this code will result in a
sub-version increase (e.g. 1.000000 to 1.000001 (1.0.1)).
CATEGORY SELECTIONS
strictures does not enable fatal warnings for all categories.
exec
Includes a warning that can cause your program to continue running
unintentionally after an internal fork. Not safe to fatalize.
recursion
Infinite recursion will end up overflowing the stack eventually
( run in 3.747 seconds using v1.01-cache-2.11-cpan-302cb4679cc )