default.yml 13 KB

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