default.yml 13 KB

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