default.yml 9.5 KB

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