default.yml 13 KB

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