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. - ../config/initializers/inflections.rb
  11. - ./rubocop_zammad.rb
  12. inherit_from:
  13. - todo.yml
  14. - todo.rspec.yml
  15. inherit_mode:
  16. merge:
  17. - Include
  18. AllCops:
  19. NewCops: enable
  20. DisplayCopNames: true
  21. Include:
  22. - '.gitlab/**/*.rb'
  23. - '.github/**/*.rb'
  24. - '.rubocop/**/*.rb'
  25. Exclude:
  26. - 'bin/*'
  27. - 'db/schema.rb'
  28. - 'vendor/**/*'
  29. - 'node_modules/**/*'
  30. - 'public/assets/**/*'
  31. - 'public/packs/**/*'
  32. RSpec:
  33. Include:
  34. - "**/*_spec.rb"
  35. - "**/*_examples.rb"
  36. Language:
  37. Expectations:
  38. - expect_no_offenses
  39. - expect_offense
  40. - adds_foreign_key
  41. - sent
  42. - not_sent
  43. Rails:
  44. Enabled: true
  45. # Zammad StyleGuide
  46. Style/FrozenStringLiteralComment:
  47. Enabled: false
  48. Layout/LineLength:
  49. Description: 'Limit lines to 80 characters.'
  50. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
  51. Enabled: false
  52. Style/NegatedIf:
  53. Description: >-
  54. Favor unless over if for negative conditions
  55. (or control flow or).
  56. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
  57. Enabled: false
  58. Style/IfUnlessModifier:
  59. Description: >-
  60. Favor modifier if/unless usage when you have a
  61. single-line body.
  62. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
  63. Enabled: false
  64. Style/TrailingCommaInArrayLiteral:
  65. Description: 'Checks for trailing comma in array literals.'
  66. StyleGuide: '#no-trailing-array-commas'
  67. Enabled: false
  68. Style/TrailingCommaInHashLiteral:
  69. Description: 'Checks for trailing comma in hash literals.'
  70. Enabled: false
  71. Style/TrailingCommaInArguments:
  72. Description: 'Checks for trailing comma in argument lists.'
  73. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
  74. Enabled: false
  75. Style/RescueStandardError:
  76. Description: 'Avoid rescuing without specifying an error class.'
  77. Enabled: true
  78. EnforcedStyle: implicit
  79. Layout/SpaceInsideReferenceBrackets:
  80. Description: 'Checks the spacing inside referential brackets.'
  81. Enabled: false
  82. Layout/SpaceInsideArrayLiteralBrackets:
  83. Description: 'Checks the spacing inside array literal brackets.'
  84. Enabled: false
  85. Style/DefWithParentheses:
  86. Description: 'Use def with parentheses when there are arguments.'
  87. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
  88. Enabled: false
  89. Style/HashSyntax:
  90. EnforcedShorthandSyntax: either
  91. Layout/HashAlignment:
  92. Description: >-
  93. Align the elements of a hash literal if they span more than
  94. one line.
  95. Enabled: true
  96. EnforcedHashRocketStyle: table
  97. EnforcedColonStyle: table
  98. EnforcedLastArgumentHashStyle: always_inspect
  99. Layout/EmptyLinesAroundClassBody:
  100. Description: "Keeps track of empty lines around class bodies."
  101. Enabled: false
  102. Layout/EmptyLinesAroundMethodBody:
  103. Description: "Keeps track of empty lines around method bodies."
  104. Enabled: false
  105. Layout/EmptyLinesAroundBlockBody:
  106. Description: "Keeps track of empty lines around block bodies."
  107. Enabled: false
  108. Layout/EmptyLinesAroundModuleBody:
  109. Description: "Keeps track of empty lines around module bodies."
  110. Enabled: false
  111. Layout/ExtraSpacing:
  112. Description: 'Do not use unnecessary spacing.'
  113. Enabled: true
  114. Exclude:
  115. - 'config/routes/**/*'
  116. - 'db/migrate/20120101000001_create_base.rb'
  117. - 'db/migrate/20120101000010_create_ticket.rb'
  118. Style/MultilineBlockChain:
  119. Description: 'Avoid multi-line chains of blocks.'
  120. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
  121. Enabled: false
  122. Metrics/ClassLength:
  123. Description: 'Avoid classes longer than 100 lines of code.'
  124. Enabled: false
  125. Metrics/MethodLength:
  126. Description: 'Avoid methods longer than 10 lines of code.'
  127. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
  128. Enabled: false
  129. Metrics/ParameterLists:
  130. Description: 'Checks for methods with too many parameters.'
  131. CountKeywordArgs: false
  132. Style/BlockComments:
  133. Description: 'Do not use block comments.'
  134. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-block-comments'
  135. Enabled: false
  136. Style/PerlBackrefs:
  137. Description: 'Avoid Perl-style regex back references.'
  138. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
  139. Enabled: false
  140. Rails/ApplicationRecord:
  141. Exclude:
  142. - 'app/models/application_model.rb'
  143. - 'app/models/active_job_lock.rb'
  144. Rails/BulkChangeTable:
  145. Description: 'Check whether alter queries are combinable.'
  146. Enabled: false
  147. Rails/FindEach:
  148. Description: 'Prefer all.find_each over all.find.'
  149. Enabled: false
  150. Rails/HasAndBelongsToMany:
  151. Description: 'Prefer has_many :through to has_and_belongs_to_many.'
  152. # StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
  153. Enabled: false
  154. Rails/I18nLocaleTexts:
  155. Description: 'Enforces use of I18n and locale files instead of locale specific strings.'
  156. Enabled: false
  157. Rails/MatchRoute:
  158. Description: >-
  159. Don't use `match` to define any routes unless there is a need to map multiple request types
  160. among [:get, :post, :patch, :put, :delete] to a single action using the `:via` option.
  161. StyleGuide: 'https://rails.rubystyle.guide/#no-match-routes'
  162. Enabled: false
  163. Rails/SkipsModelValidations:
  164. Description: >-
  165. Use methods that skips model validations with caution.
  166. See reference for more information.
  167. Reference: 'http://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
  168. Enabled: true
  169. Exclude:
  170. - test/**/*
  171. - "**/*_spec.rb"
  172. - "**/*_examples.rb"
  173. Rails/ReversibleMigration:
  174. Description: This cop checks whether the change method of the migration file is reversible.
  175. Enabled: false
  176. Style/ClassAndModuleChildren:
  177. Description: 'Checks style of children classes and modules.'
  178. Enabled: true
  179. EnforcedStyle: compact
  180. # Avoids nesting of classes and modules in sequencer code and improves readability by decreasing whitespace.
  181. # This cop is excluded for the rest of the codebase, due to following problems:
  182. # - undefined constants in path components which are not autoloaded
  183. # - changes to the lexical scope which require reference to the complete namespace of external classes
  184. # - difficult backporting due to extensive whitespace changes on all lines
  185. Include:
  186. - 'lib/sequencer/**/*.rb'
  187. Naming/FileName:
  188. Description: 'Use snake_case for source file names.'
  189. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
  190. Enabled: true
  191. Exclude:
  192. - 'script/websocket-server.rb'
  193. Naming/VariableNumber:
  194. Description: 'Use the configured style when numbering variables.'
  195. Enabled: false
  196. Naming/MethodParameterName:
  197. Description: >-
  198. Checks for method parameter names that contain capital letters,
  199. end in numbers, or do not meet a minimal length.
  200. Enabled: true
  201. AllowedNames: e, id, _, ip, to
  202. Lint/BooleanSymbol:
  203. Description: 'Check for `:true` and `:false` symbols.'
  204. Enabled: true
  205. Exclude:
  206. - "db/seeds/object_manager_attributes.rb"
  207. - "spec/requests/integration/object_manager_attributes_spec.rb"
  208. - "test/integration/object_manager_test.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"