default.yml 8.8 KB

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