.rubocop.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. require: rubocop-performance
  2. AllCops:
  3. TargetRubyVersion: 2.6.3
  4. # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
  5. # to ignore them, so only the ones explicitly set in this file are enabled.
  6. DisabledByDefault: true
  7. Exclude:
  8. - '**/templates/**/*'
  9. - '**/vendor/**/*'
  10. - '**/node_modules/**/*'
  11. Performance:
  12. Exclude:
  13. - '**/spec/**/*'
  14. Rails:
  15. Enabled: true
  16. # Prefer &&/|| over and/or.
  17. Style/AndOr:
  18. Enabled: true
  19. # Do not use braces for hash literals when they are the last argument of a
  20. # method call.
  21. Style/BracesAroundHashParameters:
  22. Enabled: true
  23. EnforcedStyle: context_dependent
  24. # Align `when` with `case`.
  25. Layout/CaseIndentation:
  26. Enabled: true
  27. # Align comments with method definitions.
  28. Layout/CommentIndentation:
  29. Enabled: true
  30. Layout/ElseAlignment:
  31. Enabled: true
  32. # Align `end` with the matching keyword or starting expression except for
  33. # assignments, where it should be aligned with the LHS.
  34. Layout/EndAlignment:
  35. Enabled: true
  36. EnforcedStyleAlignWith: variable
  37. AutoCorrect: true
  38. Layout/EmptyLineAfterMagicComment:
  39. Enabled: true
  40. Layout/EmptyLinesAroundBlockBody:
  41. Enabled: true
  42. # In a regular class definition, no empty lines around the body.
  43. Layout/EmptyLinesAroundClassBody:
  44. Enabled: true
  45. # In a regular method definition, no empty lines around the body.
  46. Layout/EmptyLinesAroundMethodBody:
  47. Enabled: true
  48. # In a regular module definition, no empty lines around the body.
  49. Layout/EmptyLinesAroundModuleBody:
  50. Enabled: true
  51. Layout/FirstParameterIndentation:
  52. Enabled: true
  53. # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
  54. Style/HashSyntax:
  55. Enabled: true
  56. # Method definitions after `private` or `protected` isolated calls need one
  57. # extra level of indentation.
  58. Layout/IndentationConsistency:
  59. Enabled: true
  60. EnforcedStyle: rails
  61. # Two spaces, no tabs (for indentation).
  62. Layout/IndentationWidth:
  63. Enabled: true
  64. Layout/LeadingCommentSpace:
  65. Enabled: true
  66. Layout/SpaceAfterColon:
  67. Enabled: true
  68. Layout/SpaceAfterComma:
  69. Enabled: true
  70. Layout/SpaceAfterSemicolon:
  71. Enabled: true
  72. Layout/SpaceAroundEqualsInParameterDefault:
  73. Enabled: true
  74. Layout/SpaceAroundKeyword:
  75. Enabled: true
  76. Layout/SpaceAroundOperators:
  77. Enabled: true
  78. Layout/SpaceBeforeComma:
  79. Enabled: true
  80. Layout/SpaceBeforeComment:
  81. Enabled: true
  82. Layout/SpaceBeforeFirstArg:
  83. Enabled: true
  84. Style/DefWithParentheses:
  85. Enabled: true
  86. # Defining a method with parameters needs parentheses.
  87. Style/MethodDefParentheses:
  88. Enabled: true
  89. Style/FrozenStringLiteralComment:
  90. Enabled: true
  91. EnforcedStyle: always
  92. # Exclude:
  93. # - 'actionview/test/**/*.builder'
  94. # - 'actionview/test/**/*.ruby'
  95. # - 'actionpack/test/**/*.builder'
  96. # - 'actionpack/test/**/*.ruby'
  97. # - 'activestorage/db/migrate/**/*.rb'
  98. # - 'activestorage/db/update_migrate/**/*.rb'
  99. # - 'actionmailbox/db/migrate/**/*.rb'
  100. # - 'actiontext/db/migrate/**/*.rb'
  101. Style/RedundantFreeze:
  102. Enabled: true
  103. # Use `foo {}` not `foo{}`.
  104. Layout/SpaceBeforeBlockBraces:
  105. Enabled: true
  106. # Use `foo { bar }` not `foo {bar}`.
  107. Layout/SpaceInsideBlockBraces:
  108. Enabled: true
  109. EnforcedStyleForEmptyBraces: space
  110. # Use `{ a: 1 }` not `{a:1}`.
  111. Layout/SpaceInsideHashLiteralBraces:
  112. Enabled: true
  113. Layout/SpaceInsideParens:
  114. Enabled: true
  115. # Check quotes usage according to lint rule below.
  116. Style/StringLiterals:
  117. Enabled: true
  118. EnforcedStyle: double_quotes
  119. # Detect hard tabs, no hard tabs.
  120. Layout/Tab:
  121. Enabled: true
  122. # Blank lines should not have any spaces.
  123. Layout/TrailingBlankLines:
  124. Enabled: true
  125. # No trailing whitespace.
  126. Layout/TrailingWhitespace:
  127. Enabled: true
  128. # Use quotes for string literals when they are enough.
  129. Style/UnneededPercentQ:
  130. Enabled: true
  131. Lint/AmbiguousOperator:
  132. Enabled: true
  133. Lint/AmbiguousRegexpLiteral:
  134. Enabled: true
  135. Lint/ErbNewArguments:
  136. Enabled: true
  137. # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
  138. Lint/RequireParentheses:
  139. Enabled: true
  140. Lint/ShadowingOuterLocalVariable:
  141. Enabled: true
  142. Lint/StringConversionInInterpolation:
  143. Enabled: true
  144. Lint/UriEscapeUnescape:
  145. Enabled: true
  146. Lint/UselessAssignment:
  147. Enabled: true
  148. Lint/DeprecatedClassMethods:
  149. Enabled: true
  150. Style/ParenthesesAroundCondition:
  151. Enabled: true
  152. Style/RedundantBegin:
  153. Enabled: true
  154. Style/RedundantReturn:
  155. Enabled: true
  156. AllowMultipleReturnValues: true
  157. Style/Semicolon:
  158. Enabled: true
  159. AllowAsExpressionSeparator: true
  160. # Prefer Foo.method over Foo::method
  161. Style/ColonMethodCall:
  162. Enabled: true
  163. Style/TrivialAccessors:
  164. Enabled: true
  165. Performance/FlatMap:
  166. Enabled: true
  167. Performance/RedundantMerge:
  168. Enabled: true
  169. Performance/StartWith:
  170. Enabled: true
  171. Performance/EndWith:
  172. Enabled: true
  173. Performance/RegexpMatch:
  174. Enabled: true
  175. Performance/ReverseEach:
  176. Enabled: true
  177. Performance/UnfreezeString:
  178. Enabled: true