Perl::Critic::Pulp − some add−on perlcritic policies
This is a collection of add-on policies for "Perl::Critic". They’re under a "pulp" theme plus other themes according to their purpose (see " POLICY THEMES " in Perl::Critic).
Check keyword arguments to "__x", "__nx", etc.
Don’t quote a version requirement like "use Foo '1.5'"
$VERSION plain number for comparisons and checking.
Avoid problems with "FOO < 123"
Avoid problems with "! $x == $y"
Dubious "@array=[1,2,3]" array/arrayref assignments.
Duplicate literal keys "%h = (xyz=>123, xyz=>456)".
Don’t use "−f".
"__PACKAGE__" etc special words not expanding.
Version requirement for hash style multi-constants.
Version requirement for constants with leading underscore.
Gtk2 module version requirement for some constants.
Perl version declared against features used.
Perl version declared against POD features used.
Prefer "File::Spec−>devnull" over /dev/null.
Put "__END__" before POD at end of file.
"Locale::TextDomain" imported but not used.
Don’t import the whole of "POSIX".
Comma "," at the end of list, if at a newline.
Semicolon ";" on the last statement of a subroutine or block.
Stray consecutive commas ",,"
Stray semicolons ";"
Unknown "\z" etc escapes in strings.
Double-colon barewords "Foo::Bar::"
No "#!" interpreter line in .pm files.
Unbalanced or mismatched ( ) parens, brackets and braces.
Put commas or some text between adjacent "L<>" links.
Avoid "C<>" in NAME section, bad for man’s "apropos" output.
Don’t "L<>" link to the document itself.
Don’t end paragraph with ".." (stray extra dot).
Verbatim paragraphs not expanding "C<>" etc markup.
Use "L<>" markup on URLs.
You can always enable or disable the policies you do or don’t want (see " CONFIGURATION " in Perl::Critic). If you haven’t already realized, there’s a wide range of builtin and add-on perlcritic policies ranging from buggy practice to the deliberately restrictive or even quite bizarre. You’re not meant to pass everything. Some policies may even be mutually contradictory.
The restrictive policies are meant as building blocks for a limited house style. For example "ProhibitBarewordDoubleColon" above, or something like "ProhibitUnlessBlocks" is another. They’re usually a matter of personal preference (and non de gustibus disputandum as they say in the classics). Trying to follow all of them would give away big parts of the language and quite likely end up with very un-typical code.
Some of the restrictive policies are geared towards beginners. "ProhibitUnknownBackslash" above or "RequireInitializationForLocalVars" are along those lines. There might for instance be good backslashing the prohibition doesn’t recognise, or for example local variable initializers make no sense for output variables like $! -- once you get to the level of knowing to use "local" to preserve such globals.
In general the POD of each policy is supposed to explain the motivation so you can see if you want it or not. If you’re not turning off or drastically customizing at least half of all policies then you’re either not trying or you’re much too easily lead!
In most of the perlcritic documentation, including the Pulp stuff here, policy names appear without the full "Perl::Critic::Policy::..." class part. In Emacs have a look at "man−completion.el" to make "M−x man" automatically expand a suffix part at point, or "ffap−perl−module.el" to go to the source similarly.
In perlcritic’s output you can ask for %P to see the full policy package name to "perldoc" or copy or follow etc. Here’s a good output format you can put in your .perlcriticrc. The file:line:column: part is a style Emacs will recognise.
verbose=%f:%l:%c:\n %P\n %m\n
See Perl::Critic::Violation for all the available "%" escapes. perlcritic.el which comes with perlcritic has regexp patterns for Emacs to recognise the builtin perlcritic formats, but it’s easier to print "file:line:column:" in the first place.
Copyright 2008, 2009, 2010, 2011, 2012 Kevin Ryde
Perl-Critic-Pulp 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 3, or (at your option) any later version.
Perl-Critic-Pulp 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 Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>.