summaryrefslogtreecommitdiff
path: root/t/data/perlcriticrc
blob: 88b36199135a3a6d4aad181da2abb28052761d6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# -*- conf -*-
#
# Default configuration for perlcritic.  Be sure to copy this into the source
# for packages that run perlcritic tests automatically during the build for
# reproducible test results.
#
# This file has been updated to match perlcritic 1.134.
#
# The canonical version of this file is maintained in the rra-c-util package,
# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
#
# Written by Russ Allbery <eagle@eyrie.org>
# Copyright 2018-2021 Russ Allbery <eagle@eyrie.org>
# Copyright 2011-2013
#     The Board of Trustees of the Leland Stanford Junior University
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# SPDX-License-Identifier: MIT

severity = 1
verbose  = %f:%l:%c: [%p] %m (%e, Severity: %s)\n

# I prefer this policy (a lot, actually), but other people in my group at
# Stanford really didn't like it, so this is my compromise to agree with a
# group coding style.
[-CodeLayout::ProhibitParensWithBuiltins]

# This recommends using given/when, but Perl has marked those as experimental
# and cautions against using when.
[-ControlStructures::ProhibitCascadingIfElse]

# Stanford's coding style allows postfix unless for flow control.  There
# doesn't appear to be any way to allow it only for flow control (the logic
# for "if" and "when" appears to be special-cased), so we have to allow unless
# globally.
[ControlStructures::ProhibitPostfixControls]
allow = unless

# This is handled with a separate test case that uses Test::Spelling.
[-Documentation::PodSpelling]

# The POD sections Perl::Critic wants are incompatible with the POD template
# from perlpodstyle, which is what I use for my POD documentation.
[-Documentation::RequirePodSections]

# This problem was fixed in Perl 5.14, which now properly preserves the value
# of $@ even if destructors run at exit from the eval block.
[-ErrorHandling::RequireCheckingReturnValueOfEval]

# This conflicts with Subroutines::ProhibitExplicitReturnUndef and
# Subroutines::RequireFinalReturn, and I prefer the brevity of the simple
# return statement.  I don't think the empty list versus undef behavior is
# that confusing.
#
# This has been renamed to Community::EmptyReturn, but excluding it by that
# name produces a warning on systems that only have the older version of the
# package.  This is handled in t/style/critic.t specially.
[-Freenode::EmptyReturn]

# The default of 9 is too small and forces weird code contortions.  After some
# experimentation, I've never found this helpful in driving useful refactors.
[-InputOutput::RequireBriefOpen]

# This is correct 80% of the time, but it isn't correct for a lot of scripts
# inside packages, where maintaining $VERSION isn't worth the effort.
# Unfortunately, there's no way to override it, so it gets turned off
# globally.
[-Modules::RequireVersionVar]

# This sounds interesting but is actually useless.  Any large blocks of
# literal text, which does not add to the complexity of the regex, will set it
# off.
[-RegularExpressions::ProhibitComplexRegexes]

# Produces false positives currently with postfix dereferencing (introduced in
# Perl 5.20).  See https://github.com/Perl-Critic/Perl-Critic/issues/578.
[-References::ProhibitDoubleSigils]

# Five arguments to a method has seemed reasonable at least once: a pair of
# input file data and path, a pair of output file descriptor and path, and
# a dict of additional arguments.
[Subroutines::ProhibitManyArgs]
skip_object = 1

# I generally don't want to require Readonly as a prerequisite for all my Perl
# modules.
[-ValuesAndExpressions::ProhibitConstantPragma]

# A good idea, but there are too many places where this would be more
# confusing than helpful.  Pull out numbers if one might change them
# independent of the algorithm, but don't do so for mathematical formulae.
[-ValuesAndExpressions::ProhibitMagicNumbers]

# This has never triggered on anything useful and keeps telling me to add
# underscores to UNIX timestamps and port numbers, which is just silly.
[-ValuesAndExpressions::RequireNumberSeparators]

# IO::Uncompress::Gunzip puts the error message in a package variable.
# Text::Wrap has a broken interface that requires use of package variables.
# YAML::XS also cannot be configured without package variables.
[Variables::ProhibitPackageVars]
add_packages = IO::Uncompress::Gunzip Text::Wrap YAML::XS

# use English was one of the worst ideas in the history of Perl.  It makes the
# code slightly more readable for amateurs at the cost of confusing
# experienced Perl programmers and sending people in futile quests for where
# these magical global variables are defined.
[-Variables::ProhibitPunctuationVars]