Perl::...::Pulp(3pm)

πŸ’… NAME πŸ’…

Perl::Critic::Pulp β€” a whole lil collection of add-on perlcritic policies ✨ (it's giving "extra rules, but make it Pulp" πŸ“)


🌸 DESCRIPTION 🌸

okay bestie, so this is a grab-bag of add-on policies for Perl::Critic. They hang out under a pulp theme, plus a bunch of other themes grouped by what they're actually for β€” peep POLICY THEMES in Perl::Critic for the receipts 🫢

πŸ› Bugs πŸ›

  • CodeLayout::ProhibitFatCommaNewline β€” don't let a newline sneak in before => when you're not quoting, bestie 😭
  • CodeLayout::ProhibitIfIfSameLine β€” watch out for } if () {, because you probably meant elsif
  • Miscellanea::TextDomainPlaceholders β€” checks the keyword arguments you hand to __x(), __nx() and friends
  • Modules::ProhibitUseQuotedVersion β€” do not quote a version requirement like use Foo '1.5'
  • ValuesAndExpressions::RequireNumericVersion β€” keep $VERSION as a plain number so comparisons and checking actually work
  • ValuesAndExpressions::ConstantBeforeLt β€” dodges the whole disaster of FOO < 123
  • ValuesAndExpressions::NotWithCompare β€” dodges the disaster of ! $x == $y
  • ValuesAndExpressions::ProhibitArrayAssignAref β€” flags those dubious @array=[1,2,3] array/arrayref assignments πŸ‘€
  • ValuesAndExpressions::ProhibitDuplicateHashKeys β€” catches duplicate literal keys like %h = (xyz=>123, xyz=>456)
  • ValuesAndExpressions::ProhibitFiletest_f β€” just don't use -f, periodt
  • ValuesAndExpressions::UnexpandedSpecialLiteral β€” for when special words like __PACKAGE__ aren't expanding the way you think

🧩 Compatibility 🧩

  • Compatibility::ConstantPragmaHash β€” the version requirement for hash-style multi-constants
  • Compatibility::ConstantLeadingUnderscore β€” the version requirement for constants with a leading underscore
  • Compatibility::Gtk2Constants β€” the Gtk2 module version requirement for certain constants
  • Compatibility::PerlMinimumVersionAndWhy β€” the Perl version you declared, checked against the features you actually used
  • Compatibility::PodMinimumVersion β€” the Perl version you declared, checked against the POD features you actually used
  • Compatibility::ProhibitUnixDevNull β€” prefer File::Spec->devnull instead of /dev/null πŸ’–

⚑ Efficiency ⚑

  • Documentation::RequireEndBeforeLastPod β€” put __END__ before the POD at the end of the file
  • Miscellanea::TextDomainUnused β€” calls out Locale::TextDomain being imported but never used
  • Modules::ProhibitPOSIXimport β€” don't import the whole entire POSIX, bestie, it's so much

πŸŽ€ Cosmetic πŸŽ€

  • CodeLayout::RequireTrailingCommaAtNewline β€” want that , comma at the end of a list when you're at a newline
  • CodeLayout::RequireFinalSemicolon β€” wants that ; semicolon on the last statement of a subroutine or block
  • ValuesAndExpressions::ProhibitEmptyCommas β€” catches stray consecutive commas ,,
  • ValuesAndExpressions::ProhibitNullStatements β€” catches stray semicolons ;
  • ValuesAndExpressions::ProhibitUnknownBackslash β€” flags unknown escapes like \z in strings
  • ValuesAndExpressions::ProhibitBarewordDoubleColon β€” no double-colon barewords like Foo::Bar::
  • Modules::ProhibitModuleShebang β€” no #! interpreter line in .pm files

πŸ“š Documentation πŸ“š

  • Documentation::ProhibitUnbalancedParens β€” unbalanced or mismatched ( ) parens, brackets and braces
  • Documentation::ProhibitAdjacentLinks β€” put commas or some text between adjacent L<> links
  • Documentation::ProhibitDuplicateHeadings β€” don't duplicate =head headings
  • Documentation::ProhibitDuplicateSeeAlso β€” don't duplicate L<> links in SEE ALSO sections
  • Documentation::ProhibitBadAproposMarkup β€” avoid C<> in the NAME section, it's bad for man's apropos output
  • Documentation::RequireFilenameMarkup β€” mark up /foo filenames, slay
  • Documentation::ProhibitLinkToSelf β€” don't L<> link to the document itself, it's giving main character energy in the worst way
  • Documentation::ProhibitParagraphEndComma β€” don't end a paragraph with a , comma
  • Documentation::ProhibitParagraphTwoDots β€” don't end a paragraph with .. (that's a stray extra dot)
  • Documentation::ProhibitVerbatimMarkup β€” verbatim paragraphs don't expand C<> etc markup
  • Documentation::RequireFinalCut β€” have a =cut at the end of the file
  • Documentation::RequireLinkedURLs β€” use L<> markup on URLs

🎯 Selecting 🎯

You can literally always enable or disable whatever policies you do or don't want (check CONFIGURATION in Perl::Critic). And you may have already clocked that there's a huge range of builtin and add-on perlcritic policies β€” everything from straight-up buggy practice to deliberately restrictive or frankly quite bizarre. You are not meant to pass everything. Some policies might even be mutually contradictory, no cap 😭

The restrictive policies are meant as building blocks for a house style. Like ProhibitBarewordDoubleColon here, or something like ProhibitUnlessBlocks. They're usually a matter of personal preference, and non de gustibus disputandum as they say in the classics. Trying to follow all such policies would give away big parts of the language and quite likely land you with very un-typical code, fr fr.

Some of the restrictive policies are geared towards beginners. ProhibitUnknownBackslash here or RequireInitializationForLocalVars are along those lines. There might for instance be good backslashing which the prohibition doesn't recognise, or 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 whether you want it or not. So 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! πŸ’…


πŸ“ OTHER NOTES πŸ“

In most of the perlcritic documentation, including the Pulp add-ons here, policy names appear without the full Perl::Critic::Policy::... class part. In Emacs try man-completion.el to make M-x man automatically expand a suffix part at point, or ffap-perl-module.el for the same to go to the source.

In perlcritic's output you can ask for %P to see the full policy package name, so you can run perldoc or copy or follow etc. Here's a good output format you can drop 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 available % escapes. perlcritic.el, which comes with perlcritic, has regexp patterns for Emacs to recognise the builtin perlcritic formats, but it's easier to output file:line:column: in the first place.


πŸ‘€ SEE ALSO πŸ‘€

Perl::Critic


🌈 HOME PAGE 🌈

<http://user42.tuxfamily.org/perl-critic-pulp/index.html>


Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2021 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/>.


ok that's the whole thing bestie, ily, now go run perlcritic and let it read you for filth πŸ’–

this was perl v5.40.1, dated 2025-10-21 β€” User Contributed Perl Documentation, and yeah we ate 🍽️✨

πŸ“¦ where this page comes from