default.yml 10 KB

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