default.yml 12 KB

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