-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.perlcriticrc
181 lines (152 loc) · 6.75 KB
/
.perlcriticrc
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
verbose = 9
# Perl::Critic::Community is nice, but contains the old name Freenode, which
# just means there's a fair bit of duplication. Annoying.
exclude = Freenode
#safari = 1
# Minimum length of regex before whining about /x; default is 0
[RegularExpressions::RequireExtendedFormatting]
minimum_regex_length_to_complain_about = 45
# Refuses unescaped spaces in regex, useful when using /x flag
# strict = 1
# Don't complain about certain postfix control structures
# until when unless when while also available
[ControlStructures::ProhibitPostfixControls]
allow = for foreach if
# Allow more space before closing filehandles, default is 9
[InputOutput::RequireBriefOpen]
lines = 25
# Don't whine for numbers above 0, 1, and 2
[ValuesAndExpressions::ProhibitMagicNumbers]
allowed_values = all_integers
## Complexity stuff
# Main script body complexity, default 20. Not a bad number to shoot for
# [Modules::ProhibitExcessMainComplexity]
# max_mccabe = 25
# Just for subroutines. The default is 20, which seems kind of high? I think
# maybe 10 is something good to shoot for, so for now let's be generous but
# slightly more strict.
[Subroutines::ProhibitExcessComplexity]
max_mccabe = 15
# Deeply nested ifs, etc. Default 5
[ControlStructures::ProhibitDeepNests]
max_nests = 3
# Unfortunately, entering *any* value overwrites the defaults, so I have to
# include the defaults here. I wish Community::DiscouragedModules or
# Community::PreferredAlternatives had options to add modules to their lists
[Modules::ProhibitEvilModules]
modules = Class::ISA Pod::Plainer Shell Switch Test::Exception {Found use of Test::Exception, use Test::Fatal instead}
# Turn off warning, since the penalty is on perls less than 5.18, which is not
# super common in my life
[-Modules::RequireNoMatchVarsWithUseEnglish]
# Backticks are mostly fine and significantly simpler than using IPC::Open3,
# so allow them when there's a return value
[InputOutput::ProhibitBacktickOperators]
only_in_void_context = 1
# Allow me to skip unpacking @_ for short subroutines, and allow accessing
# individual elements like $_[0] or array slices
[Subroutines::RequireArgUnpacking]
short_subroutine_statements = 1
allow_subscripts = 1
# Allow terminal Log::Log4perl functions
[Subroutines::RequireFinalReturn]
terminal_funcs = LOGDIE LOGEXIT
# Subroutine signatures are... fine? They have been experimental for the better
# part of a decade now but I think they're generally okay, if unused (see
# <https://github.com/Perl/perl5/issues/18537>). Perl::Critic takes umbrage
# with 'em, even beyond their "experimental" status, so let's do this. Turn off
# the "zOMG you turned off warnings!" for experimental::signatures, and then
# ease up a bit on disallowing signatures at all, lowering from severity 5 to 4,
# which is what ProhibitNoWarnings ranks as.
[TestingAndDebugging::ProhibitNoWarnings]
allow = experimental::signatures
[Subroutines::ProhibitSubroutinePrototypes]
severity = 1
# Bump these up from level 1 to level 2
[ValuesAndExpressions::ProhibitInterpolationOfLiterals]
severity = 2
[CodeLayout::ProhibitParensWithBuiltins]
severity = 2
[BuiltinFunctions::ProhibitReverseSortBlock]
severity = 2
# Lower from level 2 to level 1
[Modules::RequireVersionVar]
severity = 1
[Documentation::RequirePodSections]
severity = 1
# Lower from level 3 to level 2
# [ErrorHandling::RequireCarping]
# severity = 2
# Oh boy gotta tweak this. Good but let's leave some simple ones alone, but
# also bump things up a bit
[InputOutput::RequireCheckedSyscalls]
functions = :builtins
exclude_functions = print say
severity = 2
# Match [InputOutput::RequireCheckedOpen]
[InputOutput::RequireCheckedClose]
severity = 3
## I do not agree with these, so never load them
[-CodeLayout::ProhibitHardTabs]
# Requires /m flag on regex (^ and $ match line not just string)
[-RegularExpressions::RequireLineBoundaryMatching]
# Require /s flag on regex (. matches \n)
[-RegularExpressions::RequireDotMatchAnything]
# Don't require escape before { } ( ) . * + ? | #
[-RegularExpressions::ProhibitEscapedMetacharacters]
# Don't whine about using die or warn instead of croak or carp
[-ErrorHandling::RequireCarping]
# Don't demand long numbers have underscores, that's absurd
[-ValuesAndExpressions::RequireNumberSeparators]
# Don't worry about capitalization of variables, camelCase rules anyway
[-NamingConventions::Capitalization]
# Similar to Pulp's newline below; technically easier, but nah
[-CodeLayout::RequireTrailingCommas]
# Constant fine enough, Readonly not core, etc.
#[-ValuesAndExpressions::ProhibitConstantPragma]
## Perl::Critic::Bangs https://metacpan.org/pod/Perl::Critic::Bangs
# Allow TODOs, etc.
[-Bangs::ProhibitFlagComments]
# Add diagnostics to debugging modules
[Bangs::ProhibitDebuggingModules]
debugging_modules = diagnostics
# Raise to severity 4 from 3, despite being largely cosmetic
[Bangs::ProhibitNumberedNames]
severity = 4
[Bangs::ProhibitVagueNames]
severity = 4
## Perl::Critic::Pulp https://metacpan.org/pod/Perl::Critic::Pulp
# This feels like it should be much higher! Annoying duplication in flycheck?
[ValuesAndExpressions::ProhibitArrayAssignAref]
severity = 5
# This is a little much for personal stuff, and historically I reduced it down
# to 1, but honestly it's a good idea if only to just remind me to use the newer
# features. Only turned on if Perl::MinimumVersion is available.
# [Compatibility::PerlMinimumVersionAndWhy]
# severity = 1
# I think Perl::Critic::More has Modules::RequirePerlVersion, which allows one
# to set a minimum required version in a .perlcriticrc file. That feels a bit
# much since I don't really want the rest of Perl::Critic::More. Still, would
# be nice: 5.012 enables each @array, which is nice, and 5.020 for signatures,
# although you need 5.036 to do so without turning experimental warnings off and
# that's still too uncommon. Toolforge is on 5.028_001 as of late 2023.
# Yes, easier to maintain, but unnecessary, and I prefer the visual difference
# for the last item, just as with JavaScript
[-CodeLayout::RequireTrailingCommaAtNewline]
## Perl::Critic::Community https://metacpan.org/pod/Perl::Critic::Community
# Require while <> to do while my $line <>. I *do* agree it's better, but
# somtimes I just want something short and $_ is *quite* Perlish.
# Lower severity to 3 from 4
[Community::WhileDiamondDefaultAssignment]
severity = 3
## Perl::Critic::TooMuchCode https://metacpan.org/pod/Perl::Critic::TooMuchCode
# All are set to severity 1, which is fine, but let's bump some up a bit
[TooMuchCode::ProhibitUnusedInclude]
severity = 4
[TooMuchCode::ProhibitUnusedImport]
severity = 4
[TooMuchCode::ProhibitDuplicateSub]
severity = 4
# This is unreliable for constants that get used in regex, via ${/CONST} or
# @{[CONST]}, so may need to be turned off for the whole block.
[TooMuchCode::ProhibitUnusedConstant]
severity = 4