default.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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. GraphQL/OrderedArguments:
  251. Enabled: false
  252. GraphQL/OrderedFields:
  253. Enabled: false
  254. # Our models can have many fields, and we should not enforce a different GraphQL structure just for the sake of it.
  255. GraphQL/ExtractType:
  256. Enabled: false
  257. GraphQL/ExtractInputType:
  258. MaxArguments: 3
  259. # Run cop only for mutations: https://github.com/DmitryTsepelev/rubocop-graphql/issues/47
  260. Include:
  261. - 'app/graphql/gql/mutations/**/*.rb'
  262. # Enforcing field descriptions for all model fields will be too verbose/redundant.
  263. GraphQL/FieldDescription:
  264. Exclude:
  265. - "app/graphql/gql/types/**/*"
  266. GraphQL/ObjectDescription:
  267. Exclude:
  268. - "app/graphql/gql/fields/**/*" # false positive?
  269. - "app/graphql/gql/types/**/base_*"
  270. # RSpec tests
  271. Style/NumericPredicate:
  272. Description: >-
  273. Checks for the use of predicate- or comparison methods for
  274. numeric comparisons.
  275. StyleGuide: '#predicate-methods'
  276. # This will change to a new method call which isn't guaranteed to be on the
  277. # object. Switching these methods has to be done with knowledge of the types
  278. # of the variables which rubocop doesn't have.
  279. AutoCorrect: false
  280. Enabled: true
  281. Exclude:
  282. - "**/*_spec.rb"
  283. Lint/AmbiguousBlockAssociation:
  284. Description: >-
  285. Checks for ambiguous block association with method when param
  286. passed without parentheses.
  287. StyleGuide: '#syntax'
  288. Enabled: true
  289. Exclude:
  290. - "spec/support/*.rb"
  291. - "**/*_spec.rb"
  292. - "**/*_examples.rb"
  293. Layout/MultilineMethodCallIndentation:
  294. Description: >-
  295. Checks the indentation of the method name part in method calls
  296. that span more than one line.
  297. EnforcedStyle: indented
  298. Include:
  299. - "**/*_spec.rb"
  300. Lint/UnusedMethodArgument:
  301. AllowUnusedKeywordArguments: true
  302. Naming/PredicateName:
  303. Exclude:
  304. - "app/graphql/gql/types/**/*"
  305. RSpec/DescribeMethod:
  306. # We want to be able to split tests into subfolders, where several cases are grouped together.
  307. Description: 'Checks that the second argument to the top level describe is the tested method name.'
  308. Enabled: false
  309. RSpec/NestedGroups:
  310. Max: 6
  311. RSpecRails/AvoidSetupHook:
  312. Exclude:
  313. - "test/**/*"
  314. RSpec/AlignLeftLetBrace:
  315. Description: 'Checks that left braces for adjacent single line lets are aligned.'
  316. Enabled: true
  317. RSpec/AnyInstance:
  318. Description: 'Prefer instance doubles over stubbing any instance of a class.'
  319. Enabled: false
  320. RSpec/SubjectStub:
  321. Enabled: false
  322. RSpecRails/InferredSpecType:
  323. Description: 'Identifies redundant spec type.'
  324. Enabled: false # We use types to add DSL to rspec.
  325. RSpec/IndexedLet:
  326. Description: 'Do not set up test data using indexes (e.g., `item_1`, `item_2`).'
  327. Enabled: false
  328. Capybara/SpecificFinders:
  329. Description: 'Checks if there is a more specific finder offered by Capybara.'
  330. Enabled: false
  331. # False positives, autocorrection makes weird suggestions.
  332. Capybara/SpecificActions:
  333. Description: 'Checks for there is a more specific actions offered by Capybara.'
  334. Enabled: false
  335. Capybara/NegationMatcher:
  336. Description: Enforces use of have_no_* or not_to for negated expectations.
  337. EnforcedStyle: have_no
  338. Capybara/ClickLinkOrButtonStyle:
  339. EnforcedStyle: link_or_button
  340. RSpec/ExampleLength:
  341. CountAsOne:
  342. - 'array'
  343. - 'hash'
  344. - 'heredoc'
  345. Max: 25
  346. FactoryBot/ExcessiveCreateList:
  347. Enabled: false
  348. Zammad/PreferNegatedIfOverUnless:
  349. Exclude:
  350. - 'bin/rspec'
  351. Zammad/ExistsDateTimePrecision:
  352. Include:
  353. - "db/migrate/*.rb"
  354. - "**/db/addon/**/*.rb"
  355. Zammad/ExistsResetColumnInformation:
  356. Include:
  357. - "db/migrate/*.rb"
  358. - "**/db/addon/**/*.rb"
  359. Exclude:
  360. - 'db/migrate/201*_*.rb'
  361. - 'db/migrate/2020*_*.rb'
  362. Zammad/MigrationSchedulerLastRun:
  363. Include:
  364. - "db/migrate/*.rb"
  365. - "**/db/addon/**/*.rb"
  366. Exclude:
  367. - 'db/migrate/201*_*.rb'
  368. - 'db/migrate/2020*_*.rb'
  369. Zammad/DetectTranslatableString:
  370. Enabled: true
  371. Include:
  372. - "app/**/*.rb"
  373. - "db/**/*.rb"
  374. - "lib/**/*.rb"
  375. Exclude:
  376. - "db/migrate/**/*.rb"
  377. - "db/addon/**/*.rb"
  378. - "lib/generators/**/*.rb"
  379. - "lib/sequencer/**/*.rb"
  380. - "lib/import/**/*.rb"
  381. - "lib/tasks/**/*.rb"
  382. - "lib/fill_db.rb"
  383. Zammad/ForbidTranslatableMarker:
  384. Enabled: true
  385. Include:
  386. - "db/migrate/*.rb"
  387. Zammad/ExistsDbStrategy:
  388. Include:
  389. - "spec/**/*.rb"
  390. Exclude:
  391. - "spec/support/capybara/*.rb"