strictures-2.000006/0000755000000000000000000000000013441305326014270 5ustar00rootwheel00000000000000strictures-2.000006/inc/0000755000000000000000000000000013441305325015040 5ustar00rootwheel00000000000000strictures-2.000006/inc/ExtUtils/0000755000000000000000000000000013441305325016621 5ustar00rootwheel00000000000000strictures-2.000006/inc/ExtUtils/HasCompiler.pm0000644000000000000000000001415012705241036021366 0ustar00rootwheel00000000000000package ExtUtils::HasCompiler; $ExtUtils::HasCompiler::VERSION = '0.013'; use strict; use warnings; use base 'Exporter'; our @EXPORT_OK = qw/can_compile_loadable_object/; our %EXPORT_TAGS = (all => \@EXPORT_OK); use Config; use Carp 'carp'; use File::Basename 'basename'; use File::Spec::Functions qw/catfile catdir/; use File::Temp qw/tempdir tempfile/; my $tempdir = tempdir(CLEANUP => 1); my $loadable_object_format = <<'END'; #define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #ifndef PERL_UNUSED_VAR #define PERL_UNUSED_VAR(var) #endif XS(exported) { #ifdef dVAR dVAR; #endif dXSARGS; PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(items); /* -W */ XSRETURN_IV(42); } #ifndef XS_EXTERNAL #define XS_EXTERNAL(foo) XS(foo) #endif /* we don't want to mess with .def files on mingw */ #if defined(WIN32) && defined(__GNUC__) # define EXPORT __declspec(dllexport) #else # define EXPORT #endif EXPORT XS_EXTERNAL(boot_%s) { #ifdef dVAR dVAR; #endif dXSARGS; PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(items); /* -W */ newXS("%s::exported", exported, __FILE__); } END my $counter = 1; my %prelinking = map { $_ => 1 } qw/MSWin32 VMS aix/; sub can_compile_loadable_object { my %args = @_; my $config = $args{config} || 'ExtUtils::HasCompiler::Config'; return if not $config->get('usedl'); my ($source_handle, $source_name) = tempfile(DIR => $tempdir, SUFFIX => '.c', UNLINK => 1); my $basename = basename($source_name, '.c'); my $shortname = '_Loadable' . $counter++; my $package = "ExtUtils::HasCompiler::$shortname"; printf $source_handle $loadable_object_format, $basename, $package or do { carp "Couldn't write to $source_name: $!"; return }; close $source_handle or do { carp "Couldn't close $source_name: $!"; return }; my $abs_basename = catfile($tempdir, $basename); my $object_file = $abs_basename . $config->get('_o'); my $loadable_object = $abs_basename . '.' . $config->get('dlext'); my $incdir = catdir($config->get('archlibexp'), 'CORE'); my ($cc, $ccflags, $optimize, $cccdlflags, $ld, $ldflags, $lddlflags, $libperl, $perllibs) = map { $config->get($_) } qw/cc ccflags optimize cccdlflags ld ldflags lddlflags libperl perllibs/; if ($prelinking{$^O}) { require ExtUtils::Mksymlists; ExtUtils::Mksymlists::Mksymlists(NAME => $basename, FILE => $abs_basename, IMPORTS => {}); } my @commands; if ($^O eq 'MSWin32' && $cc =~ /^cl/) { push @commands, qq{$cc $ccflags $cccdlflags $optimize /I "$incdir" /c $source_name /Fo$object_file}; push @commands, qq{$ld $object_file $lddlflags $libperl $perllibs /out:$loadable_object /def:$abs_basename.def /pdb:$abs_basename.pdb}; } elsif ($^O eq 'VMS') { # Mksymlists is only the beginning of the story. open my $opt_fh, '>>', "$abs_basename.opt" or do { carp "Couldn't append to '$abs_basename.opt'"; return }; print $opt_fh "PerlShr/Share\n"; close $opt_fh; my $incdirs = $ccflags =~ s{ /inc[^=]+ (?:=)+ (?:\()? ( [^\/\)]* ) }{}xi ? "$1,$incdir" : $incdir; push @commands, qq{$cc $ccflags $optimize /include=($incdirs) $cccdlflags $source_name /obj=$object_file}; push @commands, qq{$ld $ldflags $lddlflags=$loadable_object $object_file,$abs_basename.opt/OPTIONS,${incdir}perlshr_attr.opt/OPTIONS' $perllibs}; } else { my @extra; if ($^O eq 'MSWin32') { my $lib = '-l' . ($libperl =~ /lib([^.]+)\./)[0]; push @extra, "$abs_basename.def", $lib, $perllibs; } elsif ($^O eq 'cygwin') { push @extra, catfile($incdir, $config->get('useshrplib') ? 'libperl.dll.a' : 'libperl.a'); } elsif ($^O eq 'aix') { $lddlflags =~ s/\Q$(BASEEXT)\E/$abs_basename/; $lddlflags =~ s/\Q$(PERL_INC)\E/$incdir/; } elsif ($^O eq 'android') { push @extra, qq{"-L$incdir"}, '-lperl', $perllibs; } push @commands, qq{$cc $ccflags $optimize "-I$incdir" $cccdlflags -c $source_name -o $object_file}; push @commands, qq{$cc $optimize $object_file -o $loadable_object $lddlflags @extra}; } for my $command (@commands) { print "$command\n" if not $args{quiet}; system $command and do { carp "Couldn't execute $command: $!"; return }; } # Skip loading when cross-compiling return 1 if exists $args{skip_load} ? $args{skip_load} : $config->get('usecrosscompile'); require DynaLoader; local @DynaLoader::dl_require_symbols = "boot_$basename"; my $handle = DynaLoader::dl_load_file(File::Spec->rel2abs($loadable_object), 0); if ($handle) { my $symbol = DynaLoader::dl_find_symbol($handle, "boot_$basename") or do { carp "Couldn't find boot symbol for $basename"; return }; my $compilet = DynaLoader::dl_install_xsub('__ANON__::__ANON__', $symbol, $source_name); my $ret = eval { $compilet->(); $package->exported } or carp $@; delete $ExtUtils::HasCompiler::{"$shortname\::"}; eval { DynaLoader::dl_unload_file($handle) } or carp $@; return defined $ret && $ret == 42; } else { carp "Couldn't load $loadable_object: " . DynaLoader::dl_error(); return; } } sub ExtUtils::HasCompiler::Config::get { my (undef, $key) = @_; return $ENV{uc $key} || $Config{$key}; } 1; # ABSTRACT: Check for the presence of a compiler __END__ =pod =encoding UTF-8 =head1 NAME ExtUtils::HasCompiler - Check for the presence of a compiler =head1 VERSION version 0.013 =head1 DESCRIPTION This module tries to check if the current system is capable of compiling, linking and loading an XS module. B: this is an early release, interface stability isn't guaranteed yet. =head1 FUNCTIONS =head2 can_compile_loadable_object(%opts) This checks if the system can compile, link and load a perl loadable object. It may take the following options: =over 4 =item * quiet Do not output the executed compilation commands. =item * config An L (compatible) object for configuration. =item * skip_load This causes can_compile_loadable_object to not try to load the generated object. This defaults to true on a cross-compiling perl. =back =head1 AUTHOR Leon Timmermans =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Leon Timmermans. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut strictures-2.000006/LICENSE0000644000000000000000000004350713441305326015306 0ustar00rootwheel00000000000000Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2019 by mst - Matt S. Trout (cpan:MSTROUT) . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2019 by mst - Matt S. Trout (cpan:MSTROUT) . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End strictures-2.000006/Changes0000644000000000000000000000734613441305263015575 0ustar00rootwheel00000000000000Release history for strictures 2.000006 - 2019-03-10 - update internal list of warnings for categories added in blead (v5.29.9) - fix extras test to avoid any files in the temp directory's parent directories interfering (RT#128751) 2.000005 - 2018-04-20 - update internal list of warnings for categories added in 5.28.0 (no behaviour change) 2.000004 - 2018-04-19 - update bundled ExtUtils::HasCompiler to 0.021 - update internal list of warnings for categories added in 5.26.0 (no behavior change) 2.000003 - 2016-04-19 - update bundled ExtUtils::HasCompiler to 0.013 to fix potential false negative (RT#113637) - list optional XS dependencies as suggests rather than recommends (RT#107393) 2.000002 - 2015-11-04 - use ExtUtils::HasCompiler to detect compiler rather than ExtUtils::CBuilder - more comprehensive testing 2.000001 - 2015-06-28 - update for perl 5.22 warning categories - avoid using goto &UNIVERSAL::VERSION on perl 5.8, since it segfaults some builds - also detect development directories based on .bzr directory - various test cleanups 2.000000 - 2015-02-26 * Incompatible Changes - strictures 2 fatalizes only a subset of warnings. Some warning categories are not safe to catch, or just inappropriate to have fatal. Existing code looking like 'use strictures 1;' will continue to get the old behavior of fatalizing all errors. The new behavior will take effect when no version or version 2 is specified. 1.005006 - 2015-01-30 - fix extra checks triggering on paths starting with t, xt, lib, or blib, rather than only triggering on those directories. - avoid stat checks for VCS directories until we are in an appropriately named file - various cleanups in test files 1.005005 - 2014-08-16 - include minimum perl version in metadata 1.005004 - 2014-03-06 - make sure meta files list extra modules as recommendations, not requirements 1.005003 - 2014-02-12 - added support for PUREPERL_ONLY (rt#91407) - fixed using strictures->VERSION to query the version (rt#92965) 1.005002 - 2013-12-10 - extra prereqs will be listed as hard prerequisites if a compiler is available 1.005001 - 2013-11-07 - fix skip on old perl on test script 1.005000 - 2013-11-05 - detect mercurial when checking for development trees - avoid using constant.pm to save a bit of memory on older perls - update to v2 metadata 1.004004 - 2012-11-12 - fix crash in 1.004003 due to qw() list being readonly 1.004003 - 2012-11-10 - check only once for presence of extra testing prereqs - explicitly specify no dynamic_config in META 1.004002 - 2012-09-08 - add better rationale for the extra testing heuristic 1.004001 - 2012-07-12 - test-specific strictures now enabled during 'dzil test' 1.004000 - 2012-07-12 - switch to testing calling file to avoid firing on dependencies 1.003001 - 2012-04-08 - fix test to handle defatalization 1.003000 - 2012-04-07 - try and run for any checkout t/ now we don't blow up the process - defatalize lack of extra testing modules - disable extra tests on perls <= 5.008003, things do not work there as expected 1.002002 - 2011-02-25 - only try and mkdir the .git if it doesn't already exist so repeated test runs don't explode 1.002001 - 2011-02-25 - switch .svn to .git in smells-of-vcs test and create it ourselves to ease importing of this dist into subversion repositories 1.002000 - 2011-02-16 - add multidimensional and bareword::filehandles in author mode 1.1.1 - 2010-12-05 - disable uninitialized warnings before calling ->SUPER::VERSION 1.1.0 - 2010-11-22 - enable extra testing only if .git or .svn present to keep requirement for extra modules author-side 1.0.0 - 2010-07-18 - initial release strictures-2.000006/MANIFEST0000644000000000000000000000101213441305326015413 0ustar00rootwheel00000000000000Changes inc/ExtUtils/HasCompiler.pm lib/strictures.pm lib/strictures/extra.pm maint/Makefile.PL.include Makefile.PL MANIFEST This list of files t/crash.t t/extras.t t/strictures.t xt/all-categories.t xt/pod.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) README README file (added by Distar) LICENSE LICENSE file (added by Distar) strictures-2.000006/t/0000755000000000000000000000000013441305325014532 5ustar00rootwheel00000000000000strictures-2.000006/t/extras.t0000644000000000000000000000602013441242750016225 0ustar00rootwheel00000000000000BEGIN { delete $ENV{PERL_STRICTURES_EXTRA} } use strict; use warnings; use Test::More 0.88; plan skip_all => 'Extra tests disabled on perls <= 5.008003' unless "$]" >= 5.008_004; use File::Temp; use File::Spec; use File::Path qw(mkpath rmtree); use Cwd 'cwd'; my %extras; BEGIN { %extras = map { $_ => 1 } qw( indirect.pm multidimensional.pm bareword/filehandles.pm ); $INC{$_} = __FILE__ for keys %extras; } use strictures (); my $indirect = 0; sub indirect::unimport { $indirect++; }; my $cwd = cwd; for my $version ( 1, 2 ) { my $tempdir = File::Temp::tempdir('strictures-XXXXXX', CLEANUP => 1, TMPDIR => 1); my $subtemp = File::Spec->catdir($tempdir, 'sub1', 'sub2'); mkpath $subtemp; chdir $subtemp; local $strictures::Smells_Like_VCS = undef; eval qq{ #line 1 "t/nogit.t" use strictures $version; 1; } or die "$@"; ok defined $strictures::Smells_Like_VCS, "VCS dir has been checked (v$version)"; ok !$strictures::Smells_Like_VCS, "VCS dir not detected with no .git (v$version)"; mkdir '.git'; { local $strictures::Smells_Like_VCS = undef; eval qq{ #line 1 "t/withgit.t" use strictures $version; 1; } or die "$@"; ok defined $strictures::Smells_Like_VCS, "VCS dir has been checked (v$version)"; ok $strictures::Smells_Like_VCS, "VCS dir detected with .git (v$version)"; } chdir $cwd; rmtree $tempdir; local $strictures::Smells_Like_VCS = 1; for my $check ( ["file.pl" => 0], ["test.pl" => 0], ["library.pm" => 0], ["t/test.t" => 1], ["xt/test.t" => 1], ["t/one.faket" => 1], ["lib/module.pm" => 1], ["other/one.pl" => 0], ["other/t/test.t" => 0], ["blib/module.pm" => 1], ) { my ($file, $want) = @$check; $indirect = 0; eval qq{ #line 1 "$file" use strictures $version; 1; } or die "$@"; my $not = $want ? '' : ' not'; is $indirect, $want, "file named $file does$not get extras (v$version)"; } { local $ENV{PERL_STRICTURES_EXTRA} = 1; local %strictures::extra_load_states = (); local @INC = (sub { die "Can't locate $_[1] in \@INC (...).\n" if $extras{$_[1]}; }, @INC); local %INC = %INC; delete $INC{$_} for keys %extras; { open my $fh, '>', \(my $str = ''); my $e; { local *STDERR = $fh; eval qq{ #line 1 "t/load_fail.t" use strictures $version; 1; } or $e = "$@"; } die $e if defined $e; like( $str, qr/Missing were:\n\n indirect multidimensional bareword::filehandles/, "failure to load all three extra deps is reported (v$version)" ); } { open my $fh, '>', \(my $str = ''); my $e; { local *STDERR = $fh; eval qq{ #line 1 "t/load_fail.t" use strictures $version; 1; } or $e = "$@"; } die $e if defined $e; is $str, '', "extra dep load failure is not reported a second time (v$version)"; } } } done_testing; strictures-2.000006/t/crash.t0000644000000000000000000000120113266371235016021 0ustar00rootwheel00000000000000use strict; use warnings FATAL => 'all'; use Test::More "$]" < 5.008004 ? ( skip_all => "can't test extra loading on perl < 5.8.4" ) : ( tests => 1 ); use File::Spec; my %extras = map { my $m = "$_.pm"; $m =~ s{::}{/}g; $m => 1 } qw( indirect multidimensional bareword::filehandles ); unshift @INC, sub { my $mod = $_[1]; die "Can't locate $mod in \@INC\n" if $extras{$mod}; return 0; }; my $err = do { local $ENV{PERL_STRICTURES_EXTRA} = 1; local *STDERR; open STDERR, '>', File::Spec->devnull; eval q{use strictures;}; $@; }; is $err, '', 'can manage to survive with some modules missing!'; strictures-2.000006/t/strictures.t0000644000000000000000000000361313266371235017141 0ustar00rootwheel00000000000000BEGIN { $ENV{PERL_STRICTURES_EXTRA} = 0 } sub _eval { eval $_[0] } use Test::More 0.88; use strict; use warnings; use Test::More; sub capture_hints { my $code = shift; $code .= q{ ; my @h; BEGIN { @h = ( $^H, ${^WARNING_BITS} ) } @h; }; my ($hints, $warning_bits) = _eval $code or die $@; # ignore lexicalized hints $hints &= ~ 0x20000; $warning_bits = unpack "H*", $warning_bits if defined $warning_bits; return ($hints, $warning_bits); } sub compare_hints { my ($code_want, $code_got, $name) = @_; my ($want_hints, $want_warnings) = capture_hints $code_want; my ($hints, $warnings) = capture_hints $code_got; is($hints, $want_hints, "Hints correct for $name"); is($warnings, $want_warnings, "Warnings correct for $name"); } compare_hints q{ use strict; use warnings FATAL => 'all'; }, q{ use strictures 1; }, 'version 1'; compare_hints q{ use strict; use warnings 'all'; use warnings FATAL => @strictures::WARNING_CATEGORIES; no warnings FATAL => @strictures::V2_NONFATAL; use warnings @strictures::V2_NONFATAL; no warnings @strictures::V2_DISABLE; }, q{ use strictures 2; }, 'version 2'; my $v; eval { $v = strictures->VERSION; 1 } or diag $@; is $v, $strictures::VERSION, '->VERSION returns version correctly'; my $next = int $strictures::VERSION + 1; eval qq{ use strictures $next; }; like $@, qr/strictures version $next required/, "Can't use strictures $next (this is version $v)"; eval qq{ use strictures {version => $next}; }; like $@, qr/Major version specified as $next - not supported/, "Can't use strictures version option $next (this is version $v)"; eval qq{ use strictures {version => undef}; }; like $@, qr/Major version specified as undef - not supported/, "Can't use strictures version option undef"; eval qq{ use strictures $strictures::VERSION; }; is $@, '', "Can use current strictures version"; done_testing; strictures-2.000006/xt/0000755000000000000000000000000013441305325014722 5ustar00rootwheel00000000000000strictures-2.000006/xt/pod.t0000644000000000000000000000036212462672050015676 0ustar00rootwheel00000000000000use Test::More; use Test::Pod; use Test::Pod::Coverage; use strict; use warnings FATAL => 'all'; pod_file_ok($_) for all_pod_files; pod_coverage_ok($_, { coverage_class => 'Pod::Coverage::CountParents' }) for all_modules; done_testing; strictures-2.000006/xt/all-categories.t0000644000000000000000000000202112463506517020006 0ustar00rootwheel00000000000000BEGIN { if (keys %INC) { print "1..0 # SKIP can't test categories with additional modules loaded\n"; exit 0; } } use strict; use warnings; BEGIN { $ENV{PERL_STRICTURES_EXTRA} = 0 } use strictures (); # avoid loading Test::More, since it adds warning categories my %known_cats; @known_cats{@strictures::WARNING_CATEGORIES} = (); my %core_cats; @core_cats{grep ! /^(?:all|everything|extra)$/, keys %warnings::Offsets} = (); my @missing = sort grep { !exists $known_cats{$_} } keys %core_cats; my @extra = sort grep { !exists $core_cats{$_} } keys %known_cats; print "1..2\n"; print((@missing ? 'not ' : '') . "ok 1 - strictures includes all warning categories\n"); if (@missing) { print STDERR "# strictures is missing categories:\n"; print STDERR "# $_\n" for @missing; } print((@extra ? 'not ' : '') . "ok 2 - strictures includes no extra categories\n"); if (@extra) { print STDERR "# strictures lists extra categories:\n"; print STDERR "# $_\n" for @extra; } if (@missing || @extra) { exit 1; } strictures-2.000006/README0000644000000000000000000002244513441305326015157 0ustar00rootwheel00000000000000NAME 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 anyway. internal Triggers deep within perl, in places that are not safe to trap. malloc Triggers deep within perl, in places that are not safe to trap. newline Includes a warning for using stat on a valid but suspect filename, ending in a newline. experimental Experimental features are used intentionally. deprecated Deprecations will inherently be added to in the future in unexpected ways, so making them fatal won't be reliable. portable Doesn't indicate an actual problem with the program, only that it may not behave properly if run on a different machine. once Can't be fatalized. Also triggers very inconsistently, so we just disable it. VERSIONS Depending on the version of strictures requested, different warnings will be enabled. If no specific version is requested, the current version's behavior will be used. Versions can be requested using perl's standard mechanism: use strictures 2; Or, by passing in a "version" option: use strictures version => 2; VERSION 2 Equivalent to: use strict; use warnings FATAL => 'all'; use warnings NONFATAL => qw( exec recursion internal malloc newline experimental deprecated portable ); no warnings 'once'; # and if in dev mode: no indirect 'fatal'; no multidimensional; no bareword::filehandles; Additionally, any warnings created by modules using warnings::register or "warnings::register_categories()" will not be fatalized. VERSION 1 Equivalent to: use strict; use warnings FATAL => 'all'; # and if in dev mode: no indirect 'fatal'; no multidimensional; no bareword::filehandles; METHODS import This method does the setup work described above in "DESCRIPTION". Optionally accepts a "version" option to request a specific version's behavior. VERSION This method traps the "strictures->VERSION(1)" call produced by a use line with a version number on it and does the version check. EXTRA TESTING RATIONALE Every so often, somebody complains that they're deploying via "git pull" and that they don't want strictures to enable itself in this case -- and that setting "PERL_STRICTURES_EXTRA" to 0 isn't acceptable (additional ways to disable extra testing would be welcome but the discussion never seems to get that far). In order to allow us to skip a couple of stages and get straight to a productive conversation, here's my current rationale for turning the extra testing on via a heuristic: The extra testing is all stuff that only ever blows up at compile time; this is intentional. So the oft-raised concern that it's different code being tested is only sort of the case -- none of the modules involved affect the final optree to my knowledge, so the author gets some additional compile time crashes which he/she then fixes, and the rest of the testing is completely valid for all environments. The point of the extra testing -- especially "no indirect" -- is to catch mistakes that newbie users won't even realise are mistakes without help. For example, foo { ... }; where foo is an & prototyped sub that you forgot to import -- this is pernicious to track down since all *seems* fine until it gets called and you get a crash. Worse still, you can fail to have imported it due to a circular require, at which point you have a load order dependent bug which I've seen before now *only* show up in production due to tiny differences between the production and the development environment. I wrote to explain this particular problem before strictures itself existed. As such, in my experience so far strictures' extra testing has *avoided* production versus development differences, not caused them. Additionally, strictures' policy is very much "try and provide as much protection as possible for newbies -- who won't think about whether there's an option to turn on or not" -- so having only the environment variable is not sufficient to achieve that (I get to explain that you need to add "use strict" at least once a week on freenode #perl -- newbies sometimes completely skip steps because they don't understand that that step is important). I make no claims that the heuristic is perfect -- it's already been evolved significantly over time, especially for 1.004 where we changed things to ensure it only fires on files in your checkout (rather than strictures-using modules you happened to have installed, which was just silly). However, I hope the above clarifies why a heuristic approach is not only necessary but desirable from a point of view of providing new users with as much safety as possible, and will allow any future discussion on the subject to focus on "how do we minimise annoyance to people deploying from checkouts intentionally". SEE ALSO * indirect * multidimensional * bareword::filehandles COMMUNITY AND SUPPORT IRC channel irc.perl.org #toolchain (or bug 'mst' in query on there or freenode) Git repository Gitweb is on http://git.shadowcat.co.uk/ and the clone URL is: git clone git://git.shadowcat.co.uk/p5sagit/strictures.git The web interface to the repository is at: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/strictures.git AUTHOR mst - Matt S. Trout (cpan:MSTROUT) CONTRIBUTORS Karen Etheridge (cpan:ETHER) Mithaldu - Christian Walde (cpan:MITHALDU) haarg - Graham Knop (cpan:HAARG) COPYRIGHT Copyright (c) 2010 the strictures "AUTHOR" and "CONTRIBUTORS" as listed above. LICENSE This library is free software and may be distributed under the same terms as perl itself. strictures-2.000006/META.yml0000644000000000000000000000203613441305325015541 0ustar00rootwheel00000000000000--- abstract: 'Turn on strict and make most warnings fatal' author: - 'mst - Matt S. Trout (cpan:MSTROUT) ' build_requires: Test::More: '0' configure_requires: {} dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: strictures no_index: directory: - t - xt - inc requires: perl: '5.006' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=strictures license: http://dev.perl.org/licenses/ repository: https://github.com/p5sagit/strictures.git version: '2.000006' x_authority: cpan:MSTROUT x_contributors: - 'Graham Knop ' - 'Karen Etheridge ' - 'Matt S Trout ' - 'Peter Rabbitson ' - 'Christian Walde ' - 'Diab Jerius ' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' strictures-2.000006/lib/0000755000000000000000000000000013441305325015035 5ustar00rootwheel00000000000000strictures-2.000006/lib/strictures/0000755000000000000000000000000013441305325017244 5ustar00rootwheel00000000000000strictures-2.000006/lib/strictures/extra.pm0000644000000000000000000000134012463506517020734 0ustar00rootwheel00000000000000package strictures::extra; use strict; use warnings FATAL => 'all'; sub import { $ENV{PERL_STRICTURES_EXTRA} = 1; } sub unimport { $ENV{PERL_STRICTURES_EXTRA} = 0; } 1; __END__ =head1 NAME strictures::extra - enable or disable strictures additional checks =head1 SYNOPSIS no strictures::extra; # will not enable indirect, multidimensional, or bareword filehandle checks use strictures; =head1 DESCRIPTION Enable or disable strictures additional checks, preventing checks for C<.git> or other VCS directories. Equivalent to setting the C environment variable. =head1 AUTHORS See L for authors. =head1 COPYRIGHT AND LICENSE See L for the copyright and license. =cut strictures-2.000006/lib/strictures.pm0000644000000000000000000003470213441305257017614 0ustar00rootwheel00000000000000package strictures; use strict; use warnings FATAL => 'all'; BEGIN { *_PERL_LT_5_8_4 = ("$]" < 5.008004) ? sub(){1} : sub(){0}; # goto &UNIVERSAL::VERSION usually works on 5.8, but fails on some ARM # machines. Seems to always work on 5.10 though. *_CAN_GOTO_VERSION = ("$]" >= 5.010000) ? sub(){1} : sub(){0}; } our $VERSION = '2.000006'; $VERSION =~ tr/_//d; our @WARNING_CATEGORIES = grep { exists $warnings::Offsets{$_} } qw( closure chmod deprecated exiting experimental experimental::alpha_assertions experimental::autoderef experimental::bitwise experimental::const_attr experimental::declared_refs experimental::lexical_subs experimental::lexical_topic experimental::postderef experimental::private_use experimental::re_strict experimental::refaliasing experimental::regex_sets experimental::script_run experimental::signatures experimental::smartmatch experimental::win32_perlio glob imprecision io closed exec layer newline pipe syscalls unopened locale misc missing numeric once overflow pack portable recursion redefine redundant regexp severe debugging inplace internal malloc shadow signal substr syntax ambiguous bareword digit illegalproto parenthesis precedence printf prototype qw reserved semicolon taint threads uninitialized umask unpack untie utf8 non_unicode nonchar surrogate void void_unusual y2k ); sub VERSION { { no warnings; local $@; if (defined $_[1] && eval { &UNIVERSAL::VERSION; 1}) { $^H |= 0x20000 unless _PERL_LT_5_8_4; $^H{strictures_enable} = int $_[1]; } } _CAN_GOTO_VERSION ? goto &UNIVERSAL::VERSION : &UNIVERSAL::VERSION; } our %extra_load_states; our $Smells_Like_VCS; sub import { my $class = shift; my %opts = @_ == 1 ? %{$_[0]} : @_; if (!exists $opts{version}) { $opts{version} = exists $^H{strictures_enable} ? delete $^H{strictures_enable} : int $VERSION; } $opts{file} = (caller)[1]; $class->_enable(\%opts); } sub _enable { my ($class, $opts) = @_; my $version = $opts->{version}; $version = 'undef' if !defined $version; my $method = "_enable_$version"; if (!$class->can($method)) { require Carp; Carp::croak("Major version specified as $version - not supported!"); } $class->$method($opts); } sub _enable_1 { my ($class, $opts) = @_; strict->import; warnings->import(FATAL => 'all'); if (_want_extra($opts->{file})) { _load_extras(qw(indirect multidimensional bareword::filehandles)); indirect->unimport(':fatal') if $extra_load_states{indirect}; multidimensional->unimport if $extra_load_states{multidimensional}; bareword::filehandles->unimport if $extra_load_states{'bareword::filehandles'}; } } our @V2_NONFATAL = grep { exists $warnings::Offsets{$_} } ( 'exec', # not safe to catch 'recursion', # will be caught by other mechanisms 'internal', # not safe to catch 'malloc', # not safe to catch 'newline', # stat on nonexistent file with a newline in it 'experimental', # no reason for these to be fatal 'deprecated', # unfortunately can't make these fatal 'portable', # everything worked fine here, just may not elsewhere ); our @V2_DISABLE = grep { exists $warnings::Offsets{$_} } ( 'once' # triggers inconsistently, can't be fatalized ); sub _enable_2 { my ($class, $opts) = @_; strict->import; warnings->import; warnings->import(FATAL => @WARNING_CATEGORIES); warnings->unimport(FATAL => @V2_NONFATAL); warnings->import(@V2_NONFATAL); warnings->unimport(@V2_DISABLE); if (_want_extra($opts->{file})) { _load_extras(qw(indirect multidimensional bareword::filehandles)); indirect->unimport(':fatal') if $extra_load_states{indirect}; multidimensional->unimport if $extra_load_states{multidimensional}; bareword::filehandles->unimport if $extra_load_states{'bareword::filehandles'}; } } sub _want_extra_env { if (exists $ENV{PERL_STRICTURES_EXTRA}) { if (_PERL_LT_5_8_4 and $ENV{PERL_STRICTURES_EXTRA}) { die 'PERL_STRICTURES_EXTRA checks are not available on perls older' . "than 5.8.4: please unset \$ENV{PERL_STRICTURES_EXTRA}\n"; } return $ENV{PERL_STRICTURES_EXTRA} ? 1 : 0; } return undef; } sub _want_extra { my $file = shift; my $want_env = _want_extra_env(); return $want_env if defined $want_env; return ( !_PERL_LT_5_8_4 and $file =~ /^(?:t|xt|lib|blib)[\\\/]/ and defined $Smells_Like_VCS ? $Smells_Like_VCS : ( $Smells_Like_VCS = !!( -e '.git' || -e '.svn' || -e '.hg' || -e '.bzr' || (-e '../../dist.ini' && (-e '../../.git' || -e '../../.svn' || -e '../../.hg' || -e '../../.bzr' )) )) ); } sub _load_extras { my @extras = @_; my @failed; foreach my $mod (@extras) { next if exists $extra_load_states{$mod}; $extra_load_states{$mod} = eval "require $mod; 1;" or do { push @failed, $mod; #work around 5.8 require bug (my $file = $mod) =~ s|::|/|g; delete $INC{"${file}.pm"}; }; } if (@failed) { my $failed = join ' ', @failed; my $extras = join ' ', @extras; print STDERR < '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 C<.git>, C<.svn>, C<.hg>, or C<.bzr> is present in the current directory (with the intention of only forcing extra tests on the author side) -- or when C<.git>, C<.svn>, C<.hg>, or C<.bzr> is present two directories up along with C (which would indicate we are in a C operation, via L) -- or when the C environment variable is set, in which case it also does the equivalent of no indirect 'fatal'; no multidimensional; no bareword::filehandles; Note that C may at some point add even more tests, with only a minor version increase, but any changes to the effect of C in normal mode will involve a major version bump. If any of the extra testing modules are not present, L will complain loudly, once, via C, and then shut up. But you really should consider installing them, they're all great anti-footgun tools. =head1 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 C 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, L 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 C environment variable. If additional useful author side checks come to mind, I'll add them to the C 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)). =head1 CATEGORY SELECTIONS strictures does not enable fatal warnings for all categories. =over 4 =item exec Includes a warning that can cause your program to continue running unintentionally after an internal fork. Not safe to fatalize. =item recursion Infinite recursion will end up overflowing the stack eventually anyway. =item internal Triggers deep within perl, in places that are not safe to trap. =item malloc Triggers deep within perl, in places that are not safe to trap. =item newline Includes a warning for using stat on a valid but suspect filename, ending in a newline. =item experimental Experimental features are used intentionally. =item deprecated Deprecations will inherently be added to in the future in unexpected ways, so making them fatal won't be reliable. =item portable Doesn't indicate an actual problem with the program, only that it may not behave properly if run on a different machine. =item once Can't be fatalized. Also triggers very inconsistently, so we just disable it. =back =head1 VERSIONS Depending on the version of strictures requested, different warnings will be enabled. If no specific version is requested, the current version's behavior will be used. Versions can be requested using perl's standard mechanism: use strictures 2; Or, by passing in a C option: use strictures version => 2; =head2 VERSION 2 Equivalent to: use strict; use warnings FATAL => 'all'; use warnings NONFATAL => qw( exec recursion internal malloc newline experimental deprecated portable ); no warnings 'once'; # and if in dev mode: no indirect 'fatal'; no multidimensional; no bareword::filehandles; Additionally, any warnings created by modules using L or C will not be fatalized. =head2 VERSION 1 Equivalent to: use strict; use warnings FATAL => 'all'; # and if in dev mode: no indirect 'fatal'; no multidimensional; no bareword::filehandles; =head1 METHODS =head2 import This method does the setup work described above in L. Optionally accepts a C option to request a specific version's behavior. =head2 VERSION This method traps the C<< strictures->VERSION(1) >> call produced by a use line with a version number on it and does the version check. =head1 EXTRA TESTING RATIONALE Every so often, somebody complains that they're deploying via C and that they don't want L to enable itself in this case -- and that setting C to 0 isn't acceptable (additional ways to disable extra testing would be welcome but the discussion never seems to get that far). In order to allow us to skip a couple of stages and get straight to a productive conversation, here's my current rationale for turning the extra testing on via a heuristic: The extra testing is all stuff that only ever blows up at compile time; this is intentional. So the oft-raised concern that it's different code being tested is only sort of the case -- none of the modules involved affect the final optree to my knowledge, so the author gets some additional compile time crashes which he/she then fixes, and the rest of the testing is completely valid for all environments. The point of the extra testing -- especially C -- is to catch mistakes that newbie users won't even realise are mistakes without help. For example, foo { ... }; where foo is an & prototyped sub that you forgot to import -- this is pernicious to track down since all I fine until it gets called and you get a crash. Worse still, you can fail to have imported it due to a circular require, at which point you have a load order dependent bug which I've seen before now I show up in production due to tiny differences between the production and the development environment. I wrote L to explain this particular problem before L itself existed. As such, in my experience so far L' extra testing has I production versus development differences, not caused them. Additionally, L' policy is very much "try and provide as much protection as possible for newbies -- who won't think about whether there's an option to turn on or not" -- so having only the environment variable is not sufficient to achieve that (I get to explain that you need to add C at least once a week on freenode #perl -- newbies sometimes completely skip steps because they don't understand that that step is important). I make no claims that the heuristic is perfect -- it's already been evolved significantly over time, especially for 1.004 where we changed things to ensure it only fires on files in your checkout (rather than L-using modules you happened to have installed, which was just silly). However, I hope the above clarifies why a heuristic approach is not only necessary but desirable from a point of view of providing new users with as much safety as possible, and will allow any future discussion on the subject to focus on "how do we minimise annoyance to people deploying from checkouts intentionally". =head1 SEE ALSO =over 4 =item * L =item * L =item * L =back =head1 COMMUNITY AND SUPPORT =head2 IRC channel irc.perl.org #toolchain (or bug 'mst' in query on there or freenode) =head2 Git repository Gitweb is on http://git.shadowcat.co.uk/ and the clone URL is: git clone git://git.shadowcat.co.uk/p5sagit/strictures.git The web interface to the repository is at: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/strictures.git =head1 AUTHOR mst - Matt S. Trout (cpan:MSTROUT) =head1 CONTRIBUTORS Karen Etheridge (cpan:ETHER) Mithaldu - Christian Walde (cpan:MITHALDU) haarg - Graham Knop (cpan:HAARG) =head1 COPYRIGHT Copyright (c) 2010 the strictures L and L as listed above. =head1 LICENSE This library is free software and may be distributed under the same terms as perl itself. =cut strictures-2.000006/Makefile.PL0000644000000000000000000000762013266371235016256 0ustar00rootwheel00000000000000use strict; use warnings FATAL => 'all'; use 5.006; use lib 'inc'; use ExtUtils::HasCompiler 'can_compile_loadable_object'; my $have_compiler = ! parse_args()->{PUREPERL_ONLY} && can_compile_loadable_object(quiet => 1); my %extra_prereqs = ( indirect => 0, multidimensional => 0, 'bareword::filehandles' => 0, ); my %META = ( name => 'strictures', license => 'perl_5', dynamic_config => 1, prereqs => { configure => { requires => { } }, build => { requires => { } }, test => { requires => { 'Test::More' => 0, } }, runtime => { requires => { perl => '5.006', }, suggests => { %extra_prereqs, }, }, develop => { requires => { 'Test::Pod' => 0, 'Test::Pod::Coverage' => 0, 'Pod::Coverage::CountParents' => 0, %extra_prereqs, } }, }, resources => { # GitHub mirrors from Shadowcat. We list it so we can get pull requests. # The canonical repo is: # r/o: git://git.shadowcat.co.uk/p5sagit/strictures.git # r/w: p5sagit@git.shadowcat.co.uk:strictures.git # web: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/strictures.git repository => { url => 'https://github.com/p5sagit/strictures.git', web => 'https://github.com/p5sagit/strictures', type => 'git', }, bugtracker => { mailto => 'bug-strictures@rt.cpan.org', web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=strictures', }, license => [ 'http://dev.perl.org/licenses/' ], }, no_index => { directory => [ 't', 'xt', 'inc' ] }, x_authority => 'cpan:MSTROUT', x_contributors => [ # manually added, from git shortlog -e -s -n 'Graham Knop ', 'Karen Etheridge ', 'Matt S Trout ', 'Peter Rabbitson ', 'Christian Walde ', 'Diab Jerius ', ], ); my %MM_ARGS = ( PREREQ_PM => { ("$]" >= 5.008004 && $have_compiler ? %extra_prereqs : () ) }, ); sub parse_args { # copied from EUMM require ExtUtils::MakeMaker; require Text::ParseWords; ExtUtils::MakeMaker::parse_args( my $tmp = {}, Text::ParseWords::shellwords($ENV{PERL_MM_OPT} || ''), @ARGV, ); return $tmp->{ARGS} || {}; } ## BOILERPLATE ############################################################### require ExtUtils::MakeMaker; (do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml'; # have to do this since old EUMM dev releases miss the eval $VERSION line my $eumm_version = eval $ExtUtils::MakeMaker::VERSION; my $mymeta = $eumm_version >= 6.57_02; my $mymeta_broken = $mymeta && $eumm_version < 6.57_07; ($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g; ($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g; $META{license} = [ $META{license} ] if $META{license} && !ref $META{license}; $MM_ARGS{LICENSE} = $META{license}[0] if $META{license} && $eumm_version >= 6.30; $MM_ARGS{NO_MYMETA} = 1 if $mymeta_broken; $MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META } unless -f 'META.yml'; for (qw(configure build test runtime)) { my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES'; my $r = $MM_ARGS{$key} = { %{$META{prereqs}{$_}{requires} || {}}, %{delete $MM_ARGS{$key} || {}}, }; defined $r->{$_} or delete $r->{$_} for keys %$r; } $MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0; delete $MM_ARGS{MIN_PERL_VERSION} if $eumm_version < 6.47_01; $MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}} if $eumm_version < 6.63_03; $MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}} if $eumm_version < 6.55_01; delete $MM_ARGS{CONFIGURE_REQUIRES} if $eumm_version < 6.51_03; ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS); ## END BOILERPLATE ########################################################### strictures-2.000006/maint/0000755000000000000000000000000013441305325015377 5ustar00rootwheel00000000000000strictures-2.000006/maint/Makefile.PL.include0000644000000000000000000000034412705235050020773 0ustar00rootwheel00000000000000BEGIN { -e 'Distar' or system("git clone git://git.shadowcat.co.uk/p5sagit/Distar.git") } use lib 'Distar/lib'; use Distar; author 'mst - Matt S. Trout (cpan:MSTROUT) '; manifest_include inc => '.pm'; 1; strictures-2.000006/META.json0000644000000000000000000000422013441305325015706 0ustar00rootwheel00000000000000{ "abstract" : "Turn on strict and make most warnings fatal", "author" : [ "mst - Matt S. Trout (cpan:MSTROUT) " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "strictures", "no_index" : { "directory" : [ "t", "xt", "inc" ] }, "prereqs" : { "build" : { "requires" : {} }, "configure" : { "requires" : {} }, "develop" : { "requires" : { "Pod::Coverage::CountParents" : "0", "Test::Pod" : "0", "Test::Pod::Coverage" : "0", "bareword::filehandles" : "0", "indirect" : "0", "multidimensional" : "0" } }, "runtime" : { "requires" : { "perl" : "5.006" }, "suggests" : { "bareword::filehandles" : "0", "indirect" : "0", "multidimensional" : "0" } }, "test" : { "requires" : { "Test::More" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-strictures@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=strictures" }, "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "type" : "git", "url" : "https://github.com/p5sagit/strictures.git", "web" : "https://github.com/p5sagit/strictures" } }, "version" : "2.000006", "x_authority" : "cpan:MSTROUT", "x_contributors" : [ "Graham Knop ", "Karen Etheridge ", "Matt S Trout ", "Peter Rabbitson ", "Christian Walde ", "Diab Jerius " ], "x_serialization_backend" : "JSON::PP version 2.97001" }