.credo.exs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. # This file contains the configuration for Credo and you are probably reading
  2. # this after creating it with `mix credo.gen.config`.
  3. #
  4. # If you find anything wrong or unclear in this file, please report an
  5. # issue on GitHub: https://github.com/rrrene/credo/issues
  6. #
  7. %{
  8. #
  9. # You can have as many configs as you like in the `configs:` field.
  10. configs: [
  11. %{
  12. #
  13. # Run any config using `mix credo -C <name>`. If no config name is given
  14. # "default" is used.
  15. #
  16. name: "default",
  17. #
  18. # These are the files included in the analysis:
  19. files: %{
  20. #
  21. # You can give explicit globs or simply directories.
  22. # In the latter case `**/*.{ex,exs}` will be used.
  23. #
  24. included: [
  25. "lib/",
  26. "test/",
  27. "extra/"
  28. ],
  29. excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
  30. },
  31. #
  32. # Load and configure plugins here:
  33. #
  34. plugins: [],
  35. #
  36. # If you create your own checks, you must specify the source files for
  37. # them here, so they can be loaded by Credo before running the analysis.
  38. #
  39. requires: [],
  40. #
  41. # If you want to enforce a style guide and need a more traditional linting
  42. # experience, you can change `strict` to `true` below:
  43. #
  44. strict: false,
  45. #
  46. # To modify the timeout for parsing files, change this value:
  47. #
  48. parse_timeout: 5000,
  49. #
  50. # If you want to use uncolored output by default, you can change `color`
  51. # to `false` below:
  52. #
  53. color: true,
  54. #
  55. # You can customize the parameters of any check by adding a second element
  56. # to the tuple.
  57. #
  58. # To disable a check put `false` as second element:
  59. #
  60. # {Credo.Check.Design.DuplicatedCode, false}
  61. #
  62. checks: %{
  63. enabled: [
  64. #
  65. ## Consistency Checks
  66. #
  67. {Credo.Check.Consistency.ExceptionNames, []},
  68. {Credo.Check.Consistency.LineEndings, []},
  69. {Credo.Check.Consistency.ParameterPatternMatching, []},
  70. {Credo.Check.Consistency.SpaceAroundOperators, []},
  71. {Credo.Check.Consistency.SpaceInParentheses, []},
  72. {Credo.Check.Consistency.TabsOrSpaces, []},
  73. #
  74. ## Design Checks
  75. #
  76. # You can customize the priority of any check
  77. # Priority values are: `low, normal, high, higher`
  78. #
  79. {Credo.Check.Design.AliasUsage,
  80. [priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
  81. # You can also customize the exit_status of each check.
  82. # If you don't want TODO comments to cause `mix credo` to fail, just
  83. # set this value to 0 (zero).
  84. #
  85. {Credo.Check.Design.TagTODO, [exit_status: 2]},
  86. {Credo.Check.Design.TagFIXME, []},
  87. #
  88. ## Readability Checks
  89. #
  90. {Credo.Check.Readability.AliasOrder, []},
  91. {Credo.Check.Readability.FunctionNames, []},
  92. {Credo.Check.Readability.LargeNumbers, []},
  93. {Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
  94. {Credo.Check.Readability.ModuleAttributeNames, []},
  95. {Credo.Check.Readability.ModuleDoc, []},
  96. {Credo.Check.Readability.ModuleNames, []},
  97. {Credo.Check.Readability.ParenthesesInCondition, []},
  98. {Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
  99. {Credo.Check.Readability.PipeIntoAnonymousFunctions, []},
  100. {Credo.Check.Readability.PredicateFunctionNames, []},
  101. {Credo.Check.Readability.PreferImplicitTry, []},
  102. {Credo.Check.Readability.RedundantBlankLines, []},
  103. {Credo.Check.Readability.Semicolons, []},
  104. {Credo.Check.Readability.SpaceAfterCommas, []},
  105. {Credo.Check.Readability.StringSigils, []},
  106. {Credo.Check.Readability.TrailingBlankLine, []},
  107. {Credo.Check.Readability.TrailingWhiteSpace, []},
  108. {Credo.Check.Readability.UnnecessaryAliasExpansion, []},
  109. {Credo.Check.Readability.VariableNames, []},
  110. {Credo.Check.Readability.WithSingleClause, []},
  111. #
  112. ## Refactoring Opportunities
  113. #
  114. {Credo.Check.Refactor.Apply, []},
  115. {Credo.Check.Refactor.CondStatements, []},
  116. {Credo.Check.Refactor.CyclomaticComplexity, false},
  117. {Credo.Check.Refactor.FunctionArity, []},
  118. {Credo.Check.Refactor.LongQuoteBlocks, []},
  119. {Credo.Check.Refactor.MatchInCondition, []},
  120. {Credo.Check.Refactor.MapJoin, []},
  121. {Credo.Check.Refactor.NegatedConditionsInUnless, []},
  122. {Credo.Check.Refactor.NegatedConditionsWithElse, false},
  123. {Credo.Check.Refactor.Nesting, []},
  124. {Credo.Check.Refactor.UnlessWithElse, []},
  125. {Credo.Check.Refactor.WithClauses, []},
  126. {Credo.Check.Refactor.FilterFilter, []},
  127. {Credo.Check.Refactor.RejectReject, []},
  128. {Credo.Check.Refactor.RedundantWithClauseResult, []},
  129. #
  130. ## Warnings
  131. #
  132. {Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
  133. {Credo.Check.Warning.BoolOperationOnSameValues, []},
  134. {Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
  135. {Credo.Check.Warning.IExPry, []},
  136. {Credo.Check.Warning.IoInspect, []},
  137. {Credo.Check.Warning.OperationOnSameValues, []},
  138. {Credo.Check.Warning.OperationWithConstantResult, []},
  139. {Credo.Check.Warning.RaiseInsideRescue, []},
  140. {Credo.Check.Warning.SpecWithStruct, []},
  141. {Credo.Check.Warning.WrongTestFileExtension, []},
  142. {Credo.Check.Warning.UnusedEnumOperation, []},
  143. {Credo.Check.Warning.UnusedFileOperation, []},
  144. {Credo.Check.Warning.UnusedKeywordOperation, []},
  145. {Credo.Check.Warning.UnusedListOperation, []},
  146. {Credo.Check.Warning.UnusedPathOperation, []},
  147. {Credo.Check.Warning.UnusedRegexOperation, []},
  148. {Credo.Check.Warning.UnusedStringOperation, []},
  149. {Credo.Check.Warning.UnusedTupleOperation, []},
  150. {Credo.Check.Warning.UnsafeExec, []}
  151. ],
  152. disabled: [
  153. #
  154. # Checks scheduled for next check update (opt-in for now, just replace `false` with `[]`)
  155. #
  156. # Controversial and experimental checks (opt-in, just move the check to `:enabled`
  157. # and be sure to use `mix credo --strict` to see low priority checks)
  158. #
  159. {Credo.Check.Consistency.MultiAliasImportRequireUse, []},
  160. {Credo.Check.Consistency.UnusedVariableNames, []},
  161. {Credo.Check.Design.DuplicatedCode, []},
  162. {Credo.Check.Design.SkipTestWithoutComment, []},
  163. {Credo.Check.Readability.AliasAs, []},
  164. {Credo.Check.Readability.BlockPipe, []},
  165. {Credo.Check.Readability.ImplTrue, []},
  166. {Credo.Check.Readability.MultiAlias, []},
  167. {Credo.Check.Readability.NestedFunctionCalls, []},
  168. {Credo.Check.Readability.SeparateAliasRequire, []},
  169. {Credo.Check.Readability.SingleFunctionToBlockPipe, []},
  170. {Credo.Check.Readability.SinglePipe, []},
  171. {Credo.Check.Readability.Specs, []},
  172. {Credo.Check.Readability.StrictModuleLayout, []},
  173. {Credo.Check.Readability.WithCustomTaggedTuple, []},
  174. {Credo.Check.Refactor.ABCSize, []},
  175. {Credo.Check.Refactor.AppendSingleItem, []},
  176. {Credo.Check.Refactor.DoubleBooleanNegation, []},
  177. {Credo.Check.Refactor.FilterReject, []},
  178. {Credo.Check.Refactor.IoPuts, []},
  179. {Credo.Check.Refactor.MapMap, []},
  180. {Credo.Check.Refactor.ModuleDependencies, []},
  181. {Credo.Check.Refactor.NegatedIsNil, []},
  182. {Credo.Check.Refactor.PipeChainStart, []},
  183. {Credo.Check.Refactor.RejectFilter, []},
  184. {Credo.Check.Refactor.VariableRebinding, []},
  185. {Credo.Check.Warning.LazyLogging, []},
  186. {Credo.Check.Warning.LeakyEnvironment, []},
  187. {Credo.Check.Warning.MapGetUnsafePass, []},
  188. {Credo.Check.Warning.MixEnv, []},
  189. {Credo.Check.Warning.UnsafeToAtom, []}
  190. # {Credo.Check.Refactor.MapInto, []},
  191. #
  192. # Custom checks can be created using `mix credo.gen.check`.
  193. #
  194. ]
  195. }
  196. }
  197. ]
  198. }