default.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. # Default enabled cops
  2. # https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml
  3. require:
  4. - rubocop-capybara
  5. - rubocop-factory_bot
  6. - rubocop-faker
  7. - rubocop-graphql
  8. - rubocop-inflector
  9. - rubocop-performance
  10. - rubocop-rails
  11. - rubocop-rspec
  12. - rubocop-rspec_rails
  13. - ../../config/initializers/inflections.rb
  14. - ./rubocop_zammad.rb
  15. inherit_from:
  16. - todo.yml
  17. - todo.rspec.yml
  18. inherit_mode:
  19. merge:
  20. - Include
  21. AllCops:
  22. NewCops: enable
  23. DisplayCopNames: true
  24. Include:
  25. - '.gitlab/**/*.rb'
  26. - '.github/**/*.rb'
  27. - '.dev/rubocop/**/*.rb'
  28. Exclude:
  29. - 'bin/*'
  30. - 'db/schema.rb'
  31. - 'vendor/**/*'
  32. - 'node_modules/**/*'
  33. - 'public/assets/**/*'
  34. - 'public/packs/**/*'
  35. RSpec:
  36. Include:
  37. - "**/*_spec.rb"
  38. - "**/*_examples.rb"
  39. Language:
  40. Expectations:
  41. - expect_no_offenses
  42. - expect_offense
  43. - adds_foreign_key
  44. - sent
  45. - not_sent
  46. Rails:
  47. Enabled: true
  48. # Zammad StyleGuide
  49. Style/FrozenStringLiteralComment:
  50. Enabled: false
  51. Layout/LineLength:
  52. Description: 'Limit lines to 80 characters.'
  53. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
  54. Enabled: false
  55. Style/NegatedIf:
  56. Description: >-
  57. Favor unless over if for negative conditions
  58. (or control flow or).
  59. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
  60. Enabled: false
  61. Style/IfUnlessModifier:
  62. Description: >-
  63. Favor modifier if/unless usage when you have a
  64. single-line body.
  65. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
  66. Enabled: false
  67. Style/TrailingCommaInArrayLiteral:
  68. Description: 'Checks for trailing comma in array literals.'
  69. StyleGuide: '#no-trailing-array-commas'
  70. Enabled: false
  71. Style/TrailingCommaInHashLiteral:
  72. Description: 'Checks for trailing comma in hash literals.'
  73. Enabled: false
  74. Style/TrailingCommaInArguments:
  75. Description: 'Checks for trailing comma in argument lists.'
  76. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
  77. Enabled: false
  78. Style/RescueStandardError:
  79. Description: 'Avoid rescuing without specifying an error class.'
  80. Enabled: true
  81. EnforcedStyle: implicit
  82. Style/FormatStringToken:
  83. Description: Use a consistent style for named format string tokens.
  84. EnforcedStyle: template
  85. # Prefer %{...} over %<...>s to make it easier for translators.
  86. Layout/SpaceInsideReferenceBrackets:
  87. Description: 'Checks the spacing inside referential brackets.'
  88. Enabled: false
  89. Layout/SpaceInsideArrayLiteralBrackets:
  90. Description: 'Checks the spacing inside array literal brackets.'
  91. Enabled: false
  92. Style/DefWithParentheses:
  93. Description: 'Use def with parentheses when there are arguments.'
  94. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
  95. Enabled: false
  96. Style/HashSyntax:
  97. EnforcedShorthandSyntax: either
  98. Layout/HashAlignment:
  99. Description: >-
  100. Align the elements of a hash literal if they span more than
  101. one line.
  102. Enabled: true
  103. EnforcedHashRocketStyle: table
  104. EnforcedColonStyle: table
  105. EnforcedLastArgumentHashStyle: always_inspect
  106. Layout/EmptyLinesAroundClassBody:
  107. Description: "Keeps track of empty lines around class bodies."
  108. Enabled: false
  109. Layout/EmptyLinesAroundMethodBody:
  110. Description: "Keeps track of empty lines around method bodies."
  111. Enabled: false
  112. Layout/EmptyLinesAroundBlockBody:
  113. Description: "Keeps track of empty lines around block bodies."
  114. Enabled: false
  115. Layout/EmptyLinesAroundModuleBody:
  116. Description: "Keeps track of empty lines around module bodies."
  117. Enabled: false
  118. Layout/ExtraSpacing:
  119. Description: 'Do not use unnecessary spacing.'
  120. Enabled: true
  121. Exclude:
  122. - 'config/routes/**/*'
  123. - 'db/migrate/20120101000001_create_base.rb'
  124. - 'db/migrate/20120101000010_create_ticket.rb'
  125. Style/MultilineBlockChain:
  126. Description: 'Avoid multi-line chains of blocks.'
  127. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
  128. Enabled: false
  129. Metrics/ClassLength:
  130. Description: 'Avoid classes longer than 100 lines of code.'
  131. Enabled: false
  132. Metrics/MethodLength:
  133. Description: 'Avoid methods longer than 10 lines of code.'
  134. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
  135. Enabled: false
  136. Metrics/ParameterLists:
  137. Description: 'Checks for methods with too many parameters.'
  138. CountKeywordArgs: false
  139. Style/BlockComments:
  140. Description: 'Do not use block comments.'
  141. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-block-comments'
  142. Enabled: false
  143. Style/PerlBackrefs:
  144. Description: 'Avoid Perl-style regex back references.'
  145. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
  146. Enabled: false
  147. Rails/ApplicationRecord:
  148. Exclude:
  149. - 'app/models/application_model.rb'
  150. - 'app/models/active_job_lock.rb'
  151. Rails/BulkChangeTable:
  152. Description: 'Check whether alter queries are combinable.'
  153. Enabled: false
  154. Rails/FindEach:
  155. Description: 'Prefer all.find_each over all.find.'
  156. Enabled: false
  157. Rails/HasAndBelongsToMany:
  158. Description: 'Prefer has_many :through to has_and_belongs_to_many.'
  159. # StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
  160. Enabled: false
  161. Rails/I18nLocaleTexts:
  162. Description: 'Enforces use of I18n and locale files instead of locale specific strings.'
  163. Enabled: false
  164. Rails/MatchRoute:
  165. Description: >-
  166. Don't use `match` to define any routes unless there is a need to map multiple request types
  167. among [:get, :post, :patch, :put, :delete] to a single action using the `:via` option.
  168. StyleGuide: 'https://rails.rubystyle.guide/#no-match-routes'
  169. Enabled: false
  170. Rails/SkipsModelValidations:
  171. Description: >-
  172. Use methods that skips model validations with caution.
  173. See reference for more information.
  174. Reference: 'http://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
  175. Enabled: true
  176. Exclude:
  177. - test/**/*
  178. - "**/*_spec.rb"
  179. - "**/*_examples.rb"
  180. Rails/ReversibleMigration:
  181. Description: This cop checks whether the change method of the migration file is reversible.
  182. Enabled: false
  183. Rails/EnvironmentVariableAccess:
  184. Description: 'This cop looks for direct access to environment variables through the ENV variable within the application code.'
  185. Enabled: true
  186. AllowReads: true
  187. Rails/Output:
  188. Exclude:
  189. - "lib/tasks/**/*"
  190. Include:
  191. - "**/*_spec.rb"
  192. Style/ClassAndModuleChildren:
  193. Description: 'Checks style of children classes and modules.'
  194. Enabled: true
  195. EnforcedStyle: compact
  196. # Avoids nesting of classes and modules in sequencer code and improves readability by decreasing whitespace.
  197. # This cop is excluded for the rest of the codebase, due to following problems:
  198. # - undefined constants in path components which are not autoloaded
  199. # - changes to the lexical scope which require reference to the complete namespace of external classes
  200. # - difficult backporting due to extensive whitespace changes on all lines
  201. Include:
  202. - 'lib/sequencer/**/*.rb'
  203. Naming/FileName:
  204. Description: 'Use snake_case for source file names.'
  205. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
  206. Enabled: true
  207. Exclude:
  208. - 'script/websocket-server.rb'
  209. Naming/VariableNumber:
  210. Description: 'Use the configured style when numbering variables.'
  211. Enabled: false
  212. Naming/MethodParameterName:
  213. Description: >-
  214. Checks for method parameter names that contain capital letters,
  215. end in numbers, or do not meet a minimal length.
  216. Enabled: true
  217. AllowedNames: e, id, _, ip, to
  218. Lint/BooleanSymbol:
  219. Description: 'Check for `:true` and `:false` symbols.'
  220. Enabled: true
  221. Exclude:
  222. - "db/seeds/object_manager_attributes.rb"
  223. - "spec/requests/integration/object_manager_attributes_spec.rb"
  224. Lint/InterpolationCheck:
  225. Description: 'Raise warning for interpolation in single q strs'
  226. Enabled: true
  227. Exclude:
  228. - "test/unit/email_process_auto_response_test.rb"
  229. - "test/unit/email_process_bounce_delivery_permanent_failed_test.rb"
  230. - "test/unit/email_process_bounce_follow_test.rb"
  231. - "test/unit/notification_factory_renderer_test.rb"
  232. - "test/unit/notification_factory_template_test.rb"
  233. - "test/unit/ticket_trigger_test.rb"
  234. - "test/unit/ticket_trigger_recursive_disabled_test.rb"
  235. Style/StringConcatenation:
  236. Description: 'Checks for places where string concatenation can be replaced with string interpolation.'
  237. StyleGuide: '#string-interpolation'
  238. Enabled: true
  239. Exclude:
  240. - "config/routes/**/*"
  241. Style/RegexpLiteral:
  242. Description: 'This cop enforces using // or %r around regular expressions.'
  243. EnforcedStyle: percent_r
  244. Style/RedundantBegin:
  245. Description: 'This cop checks for redundant `begin` blocks.'
  246. Enabled: false
  247. Style/FetchEnvVar:
  248. Description: 'This cop suggests `ENV.fetch` for the replacement of `ENV[]`.'
  249. Enabled: false
  250. Style/SafeNavigationChainLength:
  251. Description: 'This cops suggests to not use&.optional&.chaining&.too&.much'
  252. Enabled: false
  253. GraphQL/OrderedArguments:
  254. Enabled: false
  255. GraphQL/OrderedFields:
  256. Enabled: false
  257. # Our models can have many fields, and we should not enforce a different GraphQL structure just for the sake of it.
  258. GraphQL/ExtractType:
  259. Enabled: false
  260. GraphQL/ExtractInputType:
  261. MaxArguments: 3
  262. # Run cop only for mutations: https://github.com/DmitryTsepelev/rubocop-graphql/issues/47
  263. Include:
  264. - 'app/graphql/gql/mutations/**/*.rb'
  265. # Enforcing field descriptions for all model fields will be too verbose/redundant.
  266. GraphQL/FieldDescription:
  267. Exclude:
  268. - "app/graphql/gql/types/**/*"
  269. GraphQL/ObjectDescription:
  270. Exclude:
  271. - "app/graphql/gql/fields/**/*" # false positive?
  272. - "app/graphql/gql/types/**/base_*"
  273. # RSpec tests
  274. Style/NumericPredicate:
  275. Description: >-
  276. Checks for the use of predicate- or comparison methods for
  277. numeric comparisons.
  278. StyleGuide: '#predicate-methods'
  279. # This will change to a new method call which isn't guaranteed to be on the
  280. # object. Switching these methods has to be done with knowledge of the types
  281. # of the variables which rubocop doesn't have.
  282. AutoCorrect: false
  283. Enabled: true
  284. Exclude:
  285. - "**/*_spec.rb"
  286. Lint/AmbiguousBlockAssociation:
  287. Description: >-
  288. Checks for ambiguous block association with method when param
  289. passed without parentheses.
  290. StyleGuide: '#syntax'
  291. Enabled: true
  292. Exclude:
  293. - "spec/support/*.rb"
  294. - "**/*_spec.rb"
  295. - "**/*_examples.rb"
  296. Layout/MultilineMethodCallIndentation:
  297. Description: >-
  298. Checks the indentation of the method name part in method calls
  299. that span more than one line.
  300. EnforcedStyle: indented
  301. Include:
  302. - "**/*_spec.rb"
  303. Lint/UnusedMethodArgument:
  304. AllowUnusedKeywordArguments: true
  305. Naming/PredicateName:
  306. Exclude:
  307. - "app/graphql/gql/types/**/*"
  308. RSpec/DescribeMethod:
  309. # We want to be able to split tests into subfolders, where several cases are grouped together.
  310. Description: 'Checks that the second argument to the top level describe is the tested method name.'
  311. Enabled: false
  312. RSpec/NestedGroups:
  313. Max: 6
  314. RSpecRails/AvoidSetupHook:
  315. Exclude:
  316. - "test/**/*"
  317. RSpec/AlignLeftLetBrace:
  318. Description: 'Checks that left braces for adjacent single line lets are aligned.'
  319. Enabled: true
  320. RSpec/AnyInstance:
  321. Description: 'Prefer instance doubles over stubbing any instance of a class.'
  322. Enabled: false
  323. RSpec/SubjectStub:
  324. Enabled: false
  325. RSpecRails/InferredSpecType:
  326. Description: 'Identifies redundant spec type.'
  327. Enabled: false # We use types to add DSL to rspec.
  328. RSpec/IndexedLet:
  329. Description: 'Do not set up test data using indexes (e.g., `item_1`, `item_2`).'
  330. Enabled: false
  331. Capybara/SpecificFinders:
  332. Description: 'Checks if there is a more specific finder offered by Capybara.'
  333. Enabled: false
  334. # False positives, autocorrection makes weird suggestions.
  335. Capybara/SpecificActions:
  336. Description: 'Checks for there is a more specific actions offered by Capybara.'
  337. Enabled: false
  338. Capybara/NegationMatcher:
  339. Description: Enforces use of have_no_* or not_to for negated expectations.
  340. EnforcedStyle: have_no
  341. Capybara/ClickLinkOrButtonStyle:
  342. EnforcedStyle: link_or_button
  343. RSpec/ExampleLength:
  344. CountAsOne:
  345. - 'array'
  346. - 'hash'
  347. - 'heredoc'
  348. Max: 25
  349. FactoryBot/ExcessiveCreateList:
  350. Enabled: false
  351. Zammad/PreferNegatedIfOverUnless:
  352. Exclude:
  353. - 'bin/rspec'
  354. Zammad/ExistsDateTimePrecision:
  355. Include:
  356. - "db/migrate/*.rb"
  357. - "**/db/addon/**/*.rb"
  358. Zammad/ExistsResetColumnInformation:
  359. Include:
  360. - "db/migrate/*.rb"
  361. - "**/db/addon/**/*.rb"
  362. Exclude:
  363. - 'db/migrate/201*_*.rb'
  364. - 'db/migrate/2020*_*.rb'
  365. Zammad/MigrationSchedulerLastRun:
  366. Include:
  367. - "db/migrate/*.rb"
  368. - "**/db/addon/**/*.rb"
  369. Exclude:
  370. - 'db/migrate/201*_*.rb'
  371. - 'db/migrate/2020*_*.rb'
  372. Zammad/DetectTranslatableString:
  373. Enabled: true
  374. Include:
  375. - "app/**/*.rb"
  376. - "db/**/*.rb"
  377. - "lib/**/*.rb"
  378. Exclude:
  379. - "db/migrate/**/*.rb"
  380. - "db/addon/**/*.rb"
  381. - "lib/generators/**/*.rb"
  382. - "lib/sequencer/**/*.rb"
  383. - "lib/import/**/*.rb"
  384. - "lib/tasks/**/*.rb"
  385. - "lib/fill_db.rb"
  386. Zammad/ForbidTranslatableMarker:
  387. Enabled: true
  388. Include:
  389. - "db/migrate/*.rb"
  390. Zammad/ExistsDbStrategy:
  391. Include:
  392. - "spec/**/*.rb"
  393. Exclude:
  394. - "spec/support/capybara/*.rb"