.perlcriticrc 13 KB

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