.perlcriticrc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. # Troglodyne perlcritic policy, for a distribution that declares use 5.040 or
  2. # later.
  3. #
  4. # There are two of these. This one is for code that runs on a perl you control,
  5. # and perlcriticrc.compat is for code that runs on whatever perl is already
  6. # installed. The packaging-perl skill asks which you are writing before it
  7. # copies one, because the answer decides more than this file: it decides the
  8. # use line in every module and test, and perl: in prereqs.yml.
  9. #
  10. # The difference between the two is five policies. A modern perl refuses what
  11. # they report, so naming them here would buy nothing:
  12. #
  13. # TestingAndDebugging::RequireUseStrict strict is on from 5.012
  14. # Objects::ProhibitIndirectSyntax no indirect from 5.036
  15. # InputOutput::ProhibitBarewordFileHandles no bareword_filehandles from
  16. # InputOutput::ProhibitBarewordDirHandles 5.038
  17. # Modules::RequireEndWithOne module_true from 5.038
  18. #
  19. # One more goes the same way at 5.042, and is named below because this file
  20. # assumes only 5.040. Delete it once your floor is 5.041 or later, which
  21. # selects the 5.042 bundle:
  22. #
  23. # Variables::ProhibitPerl4PackageNames no apostrophe as a package
  24. # separator from 5.042
  25. #
  26. # CodeLayout::RequireASCII, which the template also names until 5.042, is off
  27. # here. See below for why.
  28. severity = 1
  29. only = 1
  30. force = 0
  31. verbose = 1
  32. criticism-fatal = 1
  33. color = 1
  34. allow-unsafe = 1
  35. # Usability
  36. [Modules::RequirePerlVersion]
  37. [Documentation::RequirePod]
  38. # Security
  39. [ValuesAndExpressions::PreventSQLInjection]
  40. # CodeLayout::RequireASCII is off, though the floor is 5.040. It also applies
  41. # to POD, and the contributors that [Git::Contributors] lists include a name
  42. # that is not ASCII. Spelling somebody's name wrong is not a code standard.
  43. [RegularExpressions::RequireDefault]
  44. strict = 1
  45. [RegularExpressions::PreventUselessMetacharacterEscapes]
  46. # PEBCAK catches
  47. [BuiltinFunctions::ProhibitDeleteOnArrays]
  48. [Subroutines::ProhibitAmbiguousFunctionCalls]
  49. [ValuesAndExpressions::ProhibitSingleArgArraySlice]
  50. [ValuesAndExpressions::ProhibitDefinedBeforeLength]
  51. [Variables::ProhibitUselessVarClearing]
  52. [Subroutines::ProhibitTailRecursion]
  53. [Bangs::ProhibitUselessRegexModifiers]
  54. [Bangs::ProhibitCommentedOutCode]
  55. [Tics::ProhibitUseBase]
  56. [Plicease::ProhibitLeadingZeros]
  57. [RegularExpressions::ProhibitEmptyAlternatives]
  58. [ValuesAndExpressions::UnexpandedSpecialLiteral]
  59. [CodeLayout::ProhibitIfIfSameLine]
  60. [ValuesAndExpressions::ConstantBeforeLt]
  61. [ValuesAndExpressions::ProhibitDuplicateHashKeys]
  62. # any access checks are necessarily a TOCTOU waiting to happen
  63. [ValuesAndExpressions::ProhibitFiletest_f]
  64. [ValuesAndExpressions::ProhibitFiletest_rwxRWX]
  65. # Bikeshed
  66. [CognitiveComplexity::ProhibitExcessCognitiveComplexity]
  67. warn_level = 40
  68. info_level = 30
  69. [Variables::ProhibitUselessInitialization]
  70. [PreferredModules]
  71. config = .preferred_modules.ini
  72. # bin/tpsgi is the PSGI application, and starts the server that runs it when it
  73. # is run itself.
  74. [logicLAB::RequireSheBang]
  75. formats = #!/usr/bin/env perl || #!/usr/bin/env tarbaby
  76. # Performance
  77. [logicLAB::ProhibitShellDispatch]
  78. [ProhibitPipeOpen]
  79. [Performance::ProhibitRegexForSimpleSubstring]
  80. [RegularExpressions::ProhibitRegexToStripAffix]
  81. [RegularExpressions::ProhibitRegexToChomp]
  82. [BuiltinFunctions::ProhibitChainingSameListSub]
  83. [RegularExpressions::ProhibitRegexForStringEquality]
  84. [Subroutines::ProhibitUnderscorePrivateSubs]
  85. [Subroutines::ProhibitSingleUseLexicalSubs]
  86. [ValuesAndExpressions::ProhibitLiteralArithmetic]
  87. [BuiltinFunctions::ProhibitIndirectBooleanGrep]
  88. # What ProhibitMutatingListFunctions reports, which this replaces, and a block
  89. # that changes $_ through a sub that it calls.
  90. [ControlStructures::ProhibitMutatingListFunctionsStricter]
  91. # An if, elsif, else or unless whose block holds no statement, a comment
  92. # being none. Loops are left alone, because a loop condition can do the work.
  93. [ControlStructures::ProhibitEmptyConditionalBlocks]
  94. # A sub that returns the result of a syscall or an eval, called where nothing
  95. # looks at the result. The same functions as RequireCheckedSyscalls below.
  96. [ErrorHandling::RequireCheckedIndirectResults]
  97. exclude_functions = print
  98. [ProhibitUseLib]
  99. [ProhibitUsageSubs]
  100. [RequireQwForLiteralLists]
  101. [ProhibitNoWarningsRedefine]
  102. [RequireFatalWarnings]
  103. [ProhibitUnusedImports]
  104. # Modules imported for a side effect rather than for a symbol, which the policy
  105. # cannot see. `re` is here because every file says `use re '/aa'`. Add your
  106. # own: IO::Prompter installs prompt() from a custom import rather than @EXPORT,
  107. # and anything loaded by name from a string is invisible the same way.
  108. # Test2::Plugin::NoWarnings fails a test that warns, and imports nothing.
  109. allow = re Test2::Plugin::NoWarnings
  110. # Off in a distribution that is only a library: it counts calls from bin/ and
  111. # lib/, and every sub a library exists to offer is called from neither -- a
  112. # module with one public sub and no bin/ reports that sub, which is the policy
  113. # working correctly and saying nothing. Turn it on for a distribution that also
  114. # ships programs, and add the authordep line to dist.ini when you do.
  115. #
  116. # allow_subs then lists the subs that are called in a way it cannot see: named
  117. # in a string and called as $obj->$name, handed to something else that calls
  118. # them, or called only from a directory it does not read. Name each one and say
  119. # which, so the next person can tell an exemption from an oversight.
  120. #
  121. # [ProhibitUnusedDefinitions]
  122. # allow_subs =
  123. # A sub that only one subclass uses, and a sub that two subclasses define where
  124. # the class above them defines none. It reads bin/ and lib/ through
  125. # Perl::Critic::Distribution, as ProhibitUnusedDefinitions does, so the two
  126. # share one parse. A library whose subclasses live in other distributions
  127. # names in allow_subs each hook that only one of its own subclasses uses.
  128. [ProhibitMisplacedMethods]
  129. [ProhibitPrintSTDERR]
  130. [InputOutput::ProhibitRepeatedPrints]
  131. # Perl::Critic's own policies. only = 1 loads nothing that is not named, so
  132. # each of these has to be, and the ones that are absent are absent on purpose.
  133. #
  134. # Not here, because something above already does the job better:
  135. # CodeLayout::ProhibitQuotedWordLists RequireQwForLiteralLists
  136. # ControlStructures::ProhibitCascadingIfElse CognitiveComplexity, which
  137. # ControlStructures::ProhibitDeepNests scores nesting and every
  138. # Subroutines::ProhibitExcessComplexity break in flow, where these
  139. # count branches
  140. # ControlStructures::ProhibitMutatingListFunctions
  141. # ProhibitMutatingListFunctionsStricter,
  142. # which reports all of it, and
  143. # a sub that the block calls
  144. # InputOutput::ProhibitBacktickOperators logicLAB::ProhibitShellDispatch
  145. # Modules::ProhibitEvilModules PreferredModules
  146. # Subroutines::ProhibitUnusedPrivateSubroutines ProhibitUnusedDefinitions,
  147. # which counts calls from bin/
  148. # and lib/, private or not
  149. # TestingAndDebugging::RequireUseWarnings RequireFatalWarnings
  150. # ValuesAndExpressions::ProhibitLeadingZeros Plicease::ProhibitLeadingZeros
  151. # Modules::RequireVersionVar [PkgVersion] in dist.ini
  152. # ErrorHandling::RequireCarping die with context, and
  153. # Carp::Always for the trace
  154. #
  155. # Nor the five the language enforces under this file's floor. The header says
  156. # which they are, and perlcriticrc.compat is where they live.
  157. #
  158. # Documentation::RequirePodSections is out as well: the sections it asks for are
  159. # the ones Pod::Weaver writes at build, and weaver.ini names them AUTHORS and
  160. # COPYRIGHT AND LICENSE where the policy wants AUTHOR and LICENSE AND COPYRIGHT.
  161. [BuiltinFunctions::ProhibitBooleanGrep]
  162. [BuiltinFunctions::ProhibitLvalueSubstr]
  163. [BuiltinFunctions::ProhibitReverseSortBlock]
  164. [BuiltinFunctions::ProhibitShiftRef]
  165. [BuiltinFunctions::ProhibitSleepViaSelect]
  166. [BuiltinFunctions::ProhibitStringyEval]
  167. [BuiltinFunctions::ProhibitStringySplit]
  168. [BuiltinFunctions::ProhibitUniversalCan]
  169. [BuiltinFunctions::ProhibitUniversalIsa]
  170. [BuiltinFunctions::ProhibitVoidGrep]
  171. [BuiltinFunctions::ProhibitVoidMap]
  172. [BuiltinFunctions::RequireBlockGrep]
  173. [BuiltinFunctions::RequireBlockMap]
  174. [BuiltinFunctions::RequireGlobFunction]
  175. [BuiltinFunctions::RequireSimpleSortBlock]
  176. [ClassHierarchies::ProhibitAutoloading]
  177. [ClassHierarchies::ProhibitExplicitISA]
  178. [ClassHierarchies::ProhibitOneArgBless]
  179. [CodeLayout::ProhibitHardTabs]
  180. [CodeLayout::ProhibitTrailingWhitespace]
  181. [CodeLayout::RequireConsistentNewlines]
  182. # [CodeLayout::RequireTidyCode] is off on purpose. git-hooks/pre-commit runs
  183. # perltidy over every staged Perl file before it runs this profile, so every
  184. # commit is tidy whatever this policy would say. In an editor, the policy only
  185. # repeated that, and ran perltidy over the whole file on every check.
  186. [CodeLayout::RequireTrailingCommas]
  187. [ControlStructures::ProhibitLabelsWithSpecialBlockNames]
  188. [ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions]
  189. [ControlStructures::ProhibitUnreachableCode]
  190. [ControlStructures::ProhibitUntilBlocks]
  191. [ControlStructures::ProhibitYadaOperator]
  192. [Documentation::PodSpelling]
  193. spell_command = aspell --lang=en_US list
  194. stop_words_file = .pod_stopwords
  195. [Documentation::RequirePackageMatchesPodName]
  196. [ErrorHandling::RequireCheckingReturnValueOfEval]
  197. [InputOutput::ProhibitExplicitStdin]
  198. [InputOutput::ProhibitInteractiveTest]
  199. [InputOutput::ProhibitJoinedReadline]
  200. [InputOutput::ProhibitOneArgSelect]
  201. [InputOutput::ProhibitReadlineInForLoop]
  202. [InputOutput::ProhibitTwoArgOpen]
  203. [InputOutput::RequireBracedFileHandleWithPrint]
  204. [InputOutput::RequireBriefOpen]
  205. [InputOutput::RequireCheckedOpen]
  206. [InputOutput::RequireCheckedSyscalls]
  207. exclude_functions = print
  208. [InputOutput::RequireEncodingWithUTF8Layer]
  209. [Miscellanea::ProhibitFormats]
  210. [Miscellanea::ProhibitTies]
  211. [Miscellanea::ProhibitUnrestrictedNoCritic]
  212. [Miscellanea::ProhibitUselessNoCritic]
  213. [Modules::ProhibitAutomaticExportation]
  214. [Modules::ProhibitConditionalUseStatements]
  215. [Modules::RequireBarewordIncludes]
  216. [Modules::RequireFilenameMatchesPackage]
  217. [Modules::RequireNoMatchVarsWithUseEnglish]
  218. [NamingConventions::Capitalization]
  219. [RegularExpressions::ProhibitCaptureWithoutTest]
  220. [RegularExpressions::ProhibitComplexRegexes]
  221. [RegularExpressions::ProhibitEnumeratedClasses]
  222. [RegularExpressions::ProhibitFixedStringMatches]
  223. [RegularExpressions::ProhibitSingleCharAlternation]
  224. [RegularExpressions::ProhibitUnusedCapture]
  225. [RegularExpressions::RequireBracesForMultiline]
  226. [RegularExpressions::RequireDotMatchAnything]
  227. [RegularExpressions::RequireExtendedFormatting]
  228. [Subroutines::ProhibitAmpersandSigils]
  229. [Subroutines::ProhibitBuiltinHomonyms]
  230. [Subroutines::ProhibitManyArgs]
  231. [Subroutines::ProhibitNestedSubs]
  232. [Subroutines::ProhibitReturnSort]
  233. [Subroutines::ProhibitSubroutinePrototypes]
  234. [Subroutines::ProtectPrivateSubs]
  235. [Subroutines::RequireArgUnpacking]
  236. [Subroutines::RequireFinalReturn]
  237. [TestingAndDebugging::ProhibitProlongedStrictureOverride]
  238. [TestingAndDebugging::RequireTestLabels]
  239. [ValuesAndExpressions::ProhibitCommaSeparatedStatements]
  240. [ValuesAndExpressions::ProhibitComplexVersion]
  241. [ValuesAndExpressions::ProhibitEscapedCharacters]
  242. [ValuesAndExpressions::ProhibitLongChainsOfMethodCalls]
  243. [ValuesAndExpressions::ProhibitMismatchedOperators]
  244. [ValuesAndExpressions::ProhibitMixedBooleanOperators]
  245. [ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters]
  246. [ValuesAndExpressions::ProhibitSpecialLiteralHeredocTerminator]
  247. [ValuesAndExpressions::ProhibitVersionStrings]
  248. [ValuesAndExpressions::RequireConstantVersion]
  249. [ValuesAndExpressions::RequireQuotedHeredocTerminator]
  250. [ValuesAndExpressions::RequireUpperCaseHeredocTerminator]
  251. [Variables::ProhibitAugmentedAssignmentInDeclaration]
  252. [Variables::ProhibitConditionalDeclarations]
  253. # Variables::ProhibitEvilVariables is not listed: it declines to load until it
  254. # is given variables to prohibit, and nobody has named any.
  255. [Variables::ProhibitLocalVars]
  256. [Variables::ProhibitMatchVars]
  257. # Drop this one at 5.041 and later, with RequireASCII above.
  258. [Variables::ProhibitPerl4PackageNames]
  259. [Variables::ProhibitReusedNames]
  260. # Stricter than the core ProhibitUnusedVariables, which reports only a bare
  261. # `my $x;` and misses a variable that is assigned and never read.
  262. [Variables::ProhibitUnusedVarsStricter]
  263. # A method takes the arguments of its interface, whether it reads them or not.
  264. allow_unused_subroutine_arguments = 1
  265. # Anything that returns a guard, which does its work by being held to the end of
  266. # its scope: a mock, a mocked file, a change of directory, a lock.
  267. # allow_if_computed_by = Test::MockModule->new Test::MockFile->file
  268. [Variables::ProtectPrivateVars]
  269. [Variables::RequireLexicalLoopIterators]
  270. [Variables::RequireLocalizedPunctuationVars]
  271. [Variables::RequireNegativeIndices]
  272. # Extensions to perl -c
  273. [CompileTime]