File Coverage

blib/lib/Perl/Critic/Pulp.pm
Criterion Covered Total %
statement 8 8 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 11 11 100.0


line stmt bran cond sub pod time code
1             # Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2021 Kevin Ryde
2              
3             # This file is part of Perl-Critic-Pulp.
4              
5             # Perl-Critic-Pulp is free software; you can redistribute it and/or modify
6             # it under the terms of the GNU General Public License as published by the
7             # Free Software Foundation; either version 3, or (at your option) any later
8             # version.
9             #
10             # Perl-Critic-Pulp is distributed in the hope that it will be useful, but
11             # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12             # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13             # for more details.
14             #
15             # You should have received a copy of the GNU General Public License along
16             # with Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>.
17              
18              
19             package Perl::Critic::Pulp;
20 42     42   1517 use 5.006;
  42         162  
21 42     42   268 use strict;
  42         91  
  42         989  
22 42     42   218 use warnings;
  42         81  
  42         2318  
23              
24             our $VERSION = 99;
25              
26             1;
27             __END__
28              
29             =for stopwords perlcritic builtin multi-constants Gtk2 Gtk2Constants perlcritic's Ryde barewords un-typical parens de gustibus disputandum backslashing initializers globals add-ons
30              
31             =head1 NAME
32              
33             Perl::Critic::Pulp - some add-on perlcritic policies
34              
35             =head1 DESCRIPTION
36              
37             This is a collection of add-on policies for C<Perl::Critic>. They're under
38             a "pulp" theme plus other themes according to their purpose (see
39             L<Perl::Critic/POLICY THEMES>).
40              
41             =for my_pod policy_list begin
42              
43             =head2 Bugs
44              
45             =over
46              
47             =item L<CodeLayout::ProhibitFatCommaNewline|Perl::Critic::Policy::CodeLayout::ProhibitFatCommaNewline>
48              
49             Avoid newline before C<=E<gt>> not quoting.
50              
51             =item L<CodeLayout::ProhibitIfIfSameLine|Perl::Critic::Policy::CodeLayout::ProhibitIfIfSameLine>
52              
53             Avoid C<} if () {> perhaps meant to be C<elsif>.
54              
55             =item L<Miscellanea::TextDomainPlaceholders|Perl::Critic::Policy::Miscellanea::TextDomainPlaceholders>
56              
57             Check keyword arguments to C<__x()>, C<__nx()>, etc.
58              
59             =item L<Modules::ProhibitUseQuotedVersion|Perl::Critic::Policy::Modules::ProhibitUseQuotedVersion>
60              
61             Don't quote a version requirement like C<use Foo '1.5'>
62              
63             =item L<ValuesAndExpressions::RequireNumericVersion|Perl::Critic::Policy::ValuesAndExpressions::RequireNumericVersion>
64              
65             C<$VERSION> plain number for comparisons and checking.
66              
67             =item L<ValuesAndExpressions::ConstantBeforeLt|Perl::Critic::Policy::ValuesAndExpressions::ConstantBeforeLt>
68              
69             Avoid problems with C<< FOO < 123 >>
70              
71             =item L<ValuesAndExpressions::NotWithCompare|Perl::Critic::Policy::ValuesAndExpressions::NotWithCompare>
72              
73             Avoid problems with C<! $x == $y>
74              
75             =item L<ValuesAndExpressions::ProhibitArrayAssignAref|Perl::Critic::Policy::ValuesAndExpressions::ProhibitArrayAssignAref>
76              
77             Dubious C<@array=[1,2,3]> array/arrayref assignments.
78              
79             =item L<ValuesAndExpressions::ProhibitDuplicateHashKeys|Perl::Critic::Policy::ValuesAndExpressions::ProhibitDuplicateHashKeys>
80              
81             Duplicate literal keys C<%h = (xyz=E<gt>123, xyz=E<gt>456)>.
82              
83             =item L<ValuesAndExpressions::ProhibitFiletest_f|Perl::Critic::Policy::ValuesAndExpressions::ProhibitFiletest_f>
84              
85             Don't use C<-f>.
86              
87             =item L<ValuesAndExpressions::UnexpandedSpecialLiteral|Perl::Critic::Policy::ValuesAndExpressions::UnexpandedSpecialLiteral>
88              
89             C<__PACKAGE__> etc special words not expanding.
90              
91             =back
92              
93             =head2 Compatibility
94              
95             =over
96              
97             =item L<Compatibility::ConstantPragmaHash|Perl::Critic::Policy::Compatibility::ConstantPragmaHash>
98              
99             Version requirement for hash style multi-constants.
100              
101             =item L<Compatibility::ConstantLeadingUnderscore|Perl::Critic::Policy::Compatibility::ConstantLeadingUnderscore>
102              
103             Version requirement for constants with leading underscore.
104              
105             =item L<Compatibility::Gtk2Constants|Perl::Critic::Policy::Compatibility::Gtk2Constants>
106              
107             Gtk2 module version requirement for some constants.
108              
109             =item L<Compatibility::PerlMinimumVersionAndWhy|Perl::Critic::Policy::Compatibility::PerlMinimumVersionAndWhy>
110              
111             Perl version declared against features used.
112              
113             =item L<Compatibility::PodMinimumVersion|Perl::Critic::Policy::Compatibility::PodMinimumVersion>
114              
115             Perl version declared against POD features used.
116              
117             =item L<Compatibility::ProhibitUnixDevNull|Perl::Critic::Policy::Compatibility::ProhibitUnixDevNull>
118              
119             Prefer C<< File::Spec->devnull >> over F</dev/null>.
120              
121             =back
122              
123             =head2 Efficiency
124              
125             =over
126              
127             =item L<Documentation::RequireEndBeforeLastPod|Perl::Critic::Policy::Documentation::RequireEndBeforeLastPod>
128              
129             Put C<__END__> before POD at end of file.
130              
131             =item L<Miscellanea::TextDomainUnused|Perl::Critic::Policy::Miscellanea::TextDomainUnused>
132              
133             C<Locale::TextDomain> imported but not used.
134              
135             =item L<Modules::ProhibitPOSIXimport|Perl::Critic::Policy::Modules::ProhibitPOSIXimport>
136              
137             Don't import the whole of C<POSIX>.
138              
139             =back
140              
141             =head2 Cosmetic
142              
143             =over
144              
145             =item L<CodeLayout::RequireTrailingCommaAtNewline|Perl::Critic::Policy::CodeLayout::RequireTrailingCommaAtNewline>
146              
147             Comma "," at the end of list, if at a newline.
148              
149             =item L<CodeLayout::RequireFinalSemicolon|Perl::Critic::Policy::CodeLayout::RequireFinalSemicolon>
150              
151             Semicolon C<;> on the last statement of a subroutine or block.
152              
153             =item L<ValuesAndExpressions::ProhibitEmptyCommas|Perl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyCommas>
154              
155             Stray consecutive commas C<,,>
156              
157             =item L<ValuesAndExpressions::ProhibitNullStatements|Perl::Critic::Policy::ValuesAndExpressions::ProhibitNullStatements>
158              
159             Stray semicolons C<;>
160              
161             =item L<ValuesAndExpressions::ProhibitUnknownBackslash|Perl::Critic::Policy::ValuesAndExpressions::ProhibitUnknownBackslash>
162              
163             Unknown C<\z> etc escapes in strings.
164              
165             =item L<ValuesAndExpressions::ProhibitBarewordDoubleColon|Perl::Critic::Policy::ValuesAndExpressions::ProhibitBarewordDoubleColon>
166              
167             Double-colon barewords C<Foo::Bar::>
168              
169             =item L<Modules::ProhibitModuleShebang|Perl::Critic::Policy::Modules::ProhibitModuleShebang>
170              
171             No C<#!> interpreter line in F<.pm> files.
172              
173             =back
174              
175             =head2 Documentation
176              
177             =over
178              
179             =item L<Documentation::ProhibitUnbalancedParens|Perl::Critic::Policy::Documentation::ProhibitUnbalancedParens>
180              
181             Unbalanced or mismatched ( ) parens, brackets and braces.
182              
183             =item L<Documentation::ProhibitAdjacentLinks|Perl::Critic::Policy::Documentation::ProhibitAdjacentLinks>
184              
185             Put commas or some text between adjacent C<< LE<lt>E<gt> >> links.
186              
187             =item L<Documentation::ProhibitDuplicateHeadings|Perl::Critic::Policy::Documentation::ProhibitDuplicateHeadings>
188              
189             Don't duplicate C<=head> headings.
190              
191             =item L<Documentation::ProhibitDuplicateSeeAlso|Perl::Critic::Policy::Documentation::ProhibitDuplicateSeeAlso>
192              
193             Don't duplicate C<< LE<lt>E<gt> >> links in SEE ALSO sections.
194              
195             =item L<Documentation::ProhibitBadAproposMarkup|Perl::Critic::Policy::Documentation::ProhibitBadAproposMarkup>
196              
197             Avoid C<< CE<lt>E<gt> >> in NAME section, bad for man's "apropos" output.
198              
199             =item L<Documentation::RequireFilenameMarkup|Perl::Critic::Policy::Documentation::RequireFilenameMarkup>
200              
201             Markup /foo filenames.
202              
203             =item L<Documentation::ProhibitLinkToSelf|Perl::Critic::Policy::Documentation::ProhibitLinkToSelf>
204              
205             Don't C<< LE<lt>E<gt> >> link to the document itself.
206              
207             =item L<Documentation::ProhibitParagraphEndComma|Perl::Critic::Policy::Documentation::ProhibitParagraphEndComma>
208              
209             Don't end paragraph with "," comma.
210              
211             =item L<Documentation::ProhibitParagraphTwoDots|Perl::Critic::Policy::Documentation::ProhibitParagraphTwoDots>
212              
213             Don't end paragraph with ".." (stray extra dot).
214              
215             =item L<Documentation::ProhibitVerbatimMarkup|Perl::Critic::Policy::Documentation::ProhibitVerbatimMarkup>
216              
217             Verbatim paragraphs not expanding C<< CE<lt>E<gt> >> etc markup.
218              
219             =item L<Documentation::RequireFinalCut|Perl::Critic::Policy::Documentation::RequireFinalCut>
220              
221             Have a C<=cut> at end of file.
222              
223             =item L<Documentation::RequireLinkedURLs|Perl::Critic::Policy::Documentation::RequireLinkedURLs>
224              
225             Use C<< LE<lt>E<gt> >> markup on URLs.
226              
227             =back
228              
229             =for my_pod policy_list end
230              
231             =head2 Selecting
232              
233             You can always enable or disable the policies you do or don't want (see
234             L<Perl::Critic/CONFIGURATION>). You may have already realized that there's
235             a wide range of builtin and add-on perlcritic policies ranging from buggy
236             practice to deliberately restrictive or even quite bizarre. You're not
237             meant to pass everything. Some policies may even be mutually contradictory.
238              
239             The restrictive policies are meant as building blocks for a house style.
240             For example C<ProhibitBarewordDoubleColon> here, or something like
241             C<ProhibitUnlessBlocks>. They're usually a matter of personal preference,
242             and "non de gustibus disputandum" as they say in the classics. Trying to
243             follow all such policies would give away big parts of the language and quite
244             likely result in very un-typical code.
245              
246             Some of the restrictive policies are geared towards beginners.
247             C<ProhibitUnknownBackslash> here or C<RequireInitializationForLocalVars> are
248             along those lines. There might for instance be good backslashing which the
249             prohibition doesn't recognise, or local variable initializers make no sense
250             for output variables like C<$!>, once you get to the level of knowing to use
251             C<local> to preserve such globals.
252              
253             In general the POD of each policy is supposed to explain the motivation so
254             you can see whether you want it or not. If you're not turning off or
255             drastically customizing at least half of all policies then you're either not
256             trying or you're much too easily lead!
257              
258             =head1 OTHER NOTES
259              
260             In most of the perlcritic documentation, including the Pulp add-ons here,
261             policy names appear without the full C<Perl::Critic::Policy::...> class
262             part. In Emacs try C<man-completion.el> to make C<M-x man> automatically
263             expand a suffix part at point, or C<ffap-perl-module.el> for the same to go
264             to the source.
265              
266             =over
267              
268             =item
269              
270             L<http://user42.tuxfamily.org/man-completion/index.html>
271              
272             =item
273              
274             L<http://user42.tuxfamily.org/ffap-perl-module/index.html>
275              
276             =back
277              
278             In perlcritic's output you can ask for C<%P> to see the full policy package
279             name to run C<perldoc> or copy or follow etc. Here's a good output format
280             you can put in your F<.perlcriticrc>. The file:line:column: part is a style
281             Emacs will recognise.
282              
283             verbose=%f:%l:%c:\n %P\n %m\n
284              
285             See L<Perl::Critic::Violation> for all available C<%> escapes.
286             C<perlcritic.el> which comes with perlcritic has regexp patterns for Emacs
287             to recognise the builtin perlcritic formats, but it's easier to output
288             "file:line:column:" in the first place.
289              
290             =head1 SEE ALSO
291              
292             L<Perl::Critic>
293              
294             =head1 HOME PAGE
295              
296             L<http://user42.tuxfamily.org/perl-critic-pulp/index.html>
297              
298             =head1 COPYRIGHT
299              
300             Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2021 Kevin Ryde
301              
302             Perl-Critic-Pulp is free software; you can redistribute it and/or modify it
303             under the terms of the GNU General Public License as published by the Free
304             Software Foundation; either version 3, or (at your option) any later
305             version.
306              
307             Perl-Critic-Pulp is distributed in the hope that it will be useful, but
308             WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
309             or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
310             more details.
311              
312             You should have received a copy of the GNU General Public License along with
313             Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>.
314              
315             =cut