default.yml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. # Default enabled cops
  2. # https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml
  3. require:
  4. - rubocop-performance
  5. - rubocop-rails
  6. - rubocop-rspec
  7. - ./rubocop_zammad.rb
  8. inherit_from:
  9. - todo.yml
  10. - todo.rspec.yml
  11. AllCops:
  12. NewCops: enable
  13. DisplayCopNames: true
  14. Exclude:
  15. - 'bin/rails'
  16. - 'bin/rake'
  17. - 'bin/spring'
  18. - 'db/schema.rb'
  19. - 'vendor/**/*'
  20. - 'node_modules/**/*'
  21. - 'public/assets/**/*'
  22. - 'public/packs/**/*'
  23. RSpec:
  24. Patterns:
  25. - '_spec.rb$'
  26. - '_examples.rb$'
  27. Rails:
  28. Enabled: true
  29. # Zammad StyleGuide
  30. Style/FrozenStringLiteralComment:
  31. Enabled: false
  32. Layout/LineLength:
  33. Description: 'Limit lines to 80 characters.'
  34. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
  35. Enabled: false
  36. Style/NegatedIf:
  37. Description: >-
  38. Favor unless over if for negative conditions
  39. (or control flow or).
  40. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
  41. Enabled: false
  42. Style/IfUnlessModifier:
  43. Description: >-
  44. Favor modifier if/unless usage when you have a
  45. single-line body.
  46. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
  47. Enabled: false
  48. Style/TrailingCommaInArrayLiteral:
  49. Description: 'Checks for trailing comma in array literals.'
  50. StyleGuide: '#no-trailing-array-commas'
  51. Enabled: false
  52. Style/TrailingCommaInHashLiteral:
  53. Description: 'Checks for trailing comma in hash literals.'
  54. Enabled: false
  55. Style/TrailingCommaInArguments:
  56. Description: 'Checks for trailing comma in argument lists.'
  57. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
  58. Enabled: false
  59. Style/RescueStandardError:
  60. Description: 'Avoid rescuing without specifying an error class.'
  61. Enabled: true
  62. EnforcedStyle: implicit
  63. Layout/SpaceInsideParens:
  64. Description: 'No spaces after ( or before ).'
  65. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-spaces-braces'
  66. Enabled: false
  67. Layout/SpaceAfterMethodName:
  68. Description: >-
  69. Do not put a space between a method name and the opening
  70. parenthesis in a method definition.
  71. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
  72. Enabled: false
  73. Layout/LeadingCommentSpace:
  74. Description: 'Comments should start with a space.'
  75. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-space'
  76. Enabled: false
  77. Style/MethodCallWithoutArgsParentheses:
  78. Description: 'Do not use parentheses for method calls with no arguments.'
  79. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens'
  80. Enabled: false
  81. Layout/SpaceInsideReferenceBrackets:
  82. Description: 'Checks the spacing inside referential brackets.'
  83. Enabled: false
  84. Layout/SpaceInsideArrayLiteralBrackets:
  85. Description: 'Checks the spacing inside array literal brackets.'
  86. Enabled: false
  87. Style/DefWithParentheses:
  88. Description: 'Use def with parentheses when there are arguments.'
  89. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
  90. Enabled: false
  91. Style/MethodDefParentheses:
  92. Description: >-
  93. Checks if the method definitions have or don't have
  94. parentheses.
  95. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
  96. Enabled: false
  97. Layout/HashAlignment:
  98. Description: >-
  99. Align the elements of a hash literal if they span more than
  100. one line.
  101. Enabled: true
  102. EnforcedHashRocketStyle: table
  103. EnforcedColonStyle: table
  104. EnforcedLastArgumentHashStyle: always_inspect
  105. Layout/EmptyLinesAroundClassBody:
  106. Description: "Keeps track of empty lines around class bodies."
  107. Enabled: false
  108. Layout/EmptyLinesAroundMethodBody:
  109. Description: "Keeps track of empty lines around method bodies."
  110. Enabled: false
  111. Layout/EmptyLinesAroundBlockBody:
  112. Description: "Keeps track of empty lines around block bodies."
  113. Enabled: false
  114. Layout/EmptyLinesAroundModuleBody:
  115. Description: "Keeps track of empty lines around module bodies."
  116. Enabled: false
  117. Layout/ExtraSpacing:
  118. Description: 'Do not use unnecessary spacing.'
  119. Enabled: true
  120. Exclude:
  121. - 'config/routes/**/*'
  122. - 'db/migrate/20120101000001_create_base.rb'
  123. - 'db/migrate/20120101000010_create_ticket.rb'
  124. Style/MultilineBlockChain:
  125. Description: 'Avoid multi-line chains of blocks.'
  126. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
  127. Enabled: false
  128. Metrics/ClassLength:
  129. Description: 'Avoid classes longer than 100 lines of code.'
  130. Enabled: false
  131. Metrics/MethodLength:
  132. Description: 'Avoid methods longer than 10 lines of code.'
  133. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
  134. Enabled: false
  135. Style/BlockComments:
  136. Description: 'Do not use block comments.'
  137. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-block-comments'
  138. Enabled: false
  139. Style/PerlBackrefs:
  140. Description: 'Avoid Perl-style regex back references.'
  141. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
  142. Enabled: false
  143. Style/HashEachMethods:
  144. Enabled: true
  145. Style/HashTransformKeys:
  146. Enabled: true
  147. Style/HashTransformValues:
  148. Enabled: true
  149. Style/SelfAssignment:
  150. Description: >-
  151. Checks for places where self-assignment shorthand should have
  152. been used.
  153. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
  154. Enabled: false
  155. Rails/ApplicationRecord:
  156. Exclude:
  157. - 'app/models/application_model.rb'
  158. - 'app/models/active_job_lock.rb'
  159. Rails/BulkChangeTable:
  160. Description: 'Check whether alter queries are combinable.'
  161. Enabled: false
  162. Rails/FindEach:
  163. Description: 'Prefer all.find_each over all.find.'
  164. Enabled: false
  165. Rails/HasAndBelongsToMany:
  166. Description: 'Prefer has_many :through to has_and_belongs_to_many.'
  167. # StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
  168. Enabled: false
  169. Rails/SkipsModelValidations:
  170. Description: >-
  171. Use methods that skips model validations with caution.
  172. See reference for more information.
  173. Reference: 'http://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
  174. Enabled: true
  175. Exclude:
  176. - test/**/*
  177. - "**/*_spec.rb"
  178. - "**/*_examples.rb"
  179. Style/ClassAndModuleChildren:
  180. Description: 'Checks style of children classes and modules.'
  181. Enabled: false
  182. Naming/FileName:
  183. Description: 'Use snake_case for source file names.'
  184. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
  185. Enabled: true
  186. Exclude:
  187. - 'script/websocket-server.rb'
  188. Naming/VariableNumber:
  189. Description: 'Use the configured style when numbering variables.'
  190. Enabled: false
  191. Naming/MethodParameterName:
  192. Description: >-
  193. Checks for method parameter names that contain capital letters,
  194. end in numbers, or do not meet a minimal length.
  195. Enabled: true
  196. AllowedNames: e, id, _, ip, to
  197. Lint/BooleanSymbol:
  198. Description: 'Check for `:true` and `:false` symbols.'
  199. Enabled: true
  200. Exclude:
  201. - "db/seeds/object_manager_attributes.rb"
  202. - "spec/requests/integration/object_manager_attributes_spec.rb"
  203. - "test/integration/object_manager_test.rb"
  204. Lint/InterpolationCheck:
  205. Description: 'Raise warning for interpolation in single q strs'
  206. Enabled: true
  207. Exclude:
  208. - "test/unit/email_process_auto_response_test.rb"
  209. - "test/unit/email_process_bounce_delivery_permanent_failed_test.rb"
  210. - "test/unit/email_process_bounce_follow_test.rb"
  211. - "test/unit/notification_factory_renderer_test.rb"
  212. - "test/unit/notification_factory_template_test.rb"
  213. - "test/unit/ticket_trigger_test.rb"
  214. - "test/unit/ticket_trigger_recursive_disabled_test.rb"
  215. # RSpec tests
  216. Style/NumericPredicate:
  217. Description: >-
  218. Checks for the use of predicate- or comparison methods for
  219. numeric comparisons.
  220. StyleGuide: '#predicate-methods'
  221. # This will change to a new method call which isn't guaranteed to be on the
  222. # object. Switching these methods has to be done with knowledge of the types
  223. # of the variables which rubocop doesn't have.
  224. AutoCorrect: false
  225. Enabled: true
  226. Exclude:
  227. - "**/*_spec.rb"
  228. Lint/AmbiguousBlockAssociation:
  229. Description: >-
  230. Checks for ambiguous block association with method when param
  231. passed without parentheses.
  232. StyleGuide: '#syntax'
  233. Enabled: true
  234. Exclude:
  235. - "spec/support/*.rb"
  236. - "**/*_spec.rb"
  237. - "**/*_examples.rb"
  238. Layout/MultilineMethodCallIndentation:
  239. Description: >-
  240. Checks the indentation of the method name part in method calls
  241. that span more than one line.
  242. EnforcedStyle: indented
  243. Include:
  244. - "**/*_spec.rb"
  245. Lint/UnusedMethodArgument:
  246. AllowUnusedKeywordArguments: true
  247. Zammad/PreferNegatedIfOverUnless:
  248. Exclude:
  249. - 'bin/rspec'