default.yml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. # Default enabled cops
  2. # https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml
  3. require:
  4. - rubocop-faker
  5. - rubocop-performance
  6. - rubocop-rails
  7. - rubocop-rspec
  8. - ./rubocop_zammad.rb
  9. inherit_from:
  10. - todo.yml
  11. - todo.rspec.yml
  12. inherit_mode:
  13. merge:
  14. - Include
  15. AllCops:
  16. NewCops: enable
  17. DisplayCopNames: true
  18. Include:
  19. - '.gitlab/**/*.rb'
  20. - '.github/**/*.rb'
  21. - '.rubocop/**/*.rb'
  22. Exclude:
  23. - 'bin/*'
  24. - 'db/schema.rb'
  25. - 'vendor/**/*'
  26. - 'node_modules/**/*'
  27. - 'public/assets/**/*'
  28. - 'public/packs/**/*'
  29. RSpec:
  30. Include:
  31. - "**/*_spec.rb"
  32. - "**/*_examples.rb"
  33. Rails:
  34. Enabled: true
  35. # Zammad StyleGuide
  36. Style/FrozenStringLiteralComment:
  37. Enabled: false
  38. Layout/LineLength:
  39. Description: 'Limit lines to 80 characters.'
  40. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
  41. Enabled: false
  42. Style/NegatedIf:
  43. Description: >-
  44. Favor unless over if for negative conditions
  45. (or control flow or).
  46. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
  47. Enabled: false
  48. Style/IfUnlessModifier:
  49. Description: >-
  50. Favor modifier if/unless usage when you have a
  51. single-line body.
  52. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
  53. Enabled: false
  54. Style/TrailingCommaInArrayLiteral:
  55. Description: 'Checks for trailing comma in array literals.'
  56. StyleGuide: '#no-trailing-array-commas'
  57. Enabled: false
  58. Style/TrailingCommaInHashLiteral:
  59. Description: 'Checks for trailing comma in hash literals.'
  60. Enabled: false
  61. Style/TrailingCommaInArguments:
  62. Description: 'Checks for trailing comma in argument lists.'
  63. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
  64. Enabled: false
  65. Style/RescueStandardError:
  66. Description: 'Avoid rescuing without specifying an error class.'
  67. Enabled: true
  68. EnforcedStyle: implicit
  69. Layout/SpaceInsideParens:
  70. Description: 'No spaces after ( or before ).'
  71. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-spaces-braces'
  72. Enabled: false
  73. Layout/SpaceAfterMethodName:
  74. Description: >-
  75. Do not put a space between a method name and the opening
  76. parenthesis in a method definition.
  77. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
  78. Enabled: false
  79. Layout/LeadingCommentSpace:
  80. Description: 'Comments should start with a space.'
  81. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-space'
  82. Enabled: false
  83. Style/MethodCallWithoutArgsParentheses:
  84. Description: 'Do not use parentheses for method calls with no arguments.'
  85. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens'
  86. Enabled: false
  87. Layout/SpaceInsideReferenceBrackets:
  88. Description: 'Checks the spacing inside referential brackets.'
  89. Enabled: false
  90. Layout/SpaceInsideArrayLiteralBrackets:
  91. Description: 'Checks the spacing inside array literal brackets.'
  92. Enabled: false
  93. Style/DefWithParentheses:
  94. Description: 'Use def with parentheses when there are arguments.'
  95. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
  96. Enabled: false
  97. Style/MethodDefParentheses:
  98. Description: >-
  99. Checks if the method definitions have or don't have
  100. parentheses.
  101. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
  102. Enabled: false
  103. Layout/HashAlignment:
  104. Description: >-
  105. Align the elements of a hash literal if they span more than
  106. one line.
  107. Enabled: true
  108. EnforcedHashRocketStyle: table
  109. EnforcedColonStyle: table
  110. EnforcedLastArgumentHashStyle: always_inspect
  111. Layout/EmptyLinesAroundClassBody:
  112. Description: "Keeps track of empty lines around class bodies."
  113. Enabled: false
  114. Layout/EmptyLinesAroundMethodBody:
  115. Description: "Keeps track of empty lines around method bodies."
  116. Enabled: false
  117. Layout/EmptyLinesAroundBlockBody:
  118. Description: "Keeps track of empty lines around block bodies."
  119. Enabled: false
  120. Layout/EmptyLinesAroundModuleBody:
  121. Description: "Keeps track of empty lines around module bodies."
  122. Enabled: false
  123. Layout/ExtraSpacing:
  124. Description: 'Do not use unnecessary spacing.'
  125. Enabled: true
  126. Exclude:
  127. - 'config/routes/**/*'
  128. - 'db/migrate/20120101000001_create_base.rb'
  129. - 'db/migrate/20120101000010_create_ticket.rb'
  130. Style/MultilineBlockChain:
  131. Description: 'Avoid multi-line chains of blocks.'
  132. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
  133. Enabled: false
  134. Metrics/ClassLength:
  135. Description: 'Avoid classes longer than 100 lines of code.'
  136. Enabled: false
  137. Metrics/MethodLength:
  138. Description: 'Avoid methods longer than 10 lines of code.'
  139. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
  140. Enabled: false
  141. Style/BlockComments:
  142. Description: 'Do not use block comments.'
  143. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-block-comments'
  144. Enabled: false
  145. Style/PerlBackrefs:
  146. Description: 'Avoid Perl-style regex back references.'
  147. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
  148. Enabled: false
  149. Style/HashEachMethods:
  150. Enabled: true
  151. Style/HashTransformKeys:
  152. Enabled: true
  153. Style/HashTransformValues:
  154. Enabled: true
  155. Style/SelfAssignment:
  156. Description: >-
  157. Checks for places where self-assignment shorthand should have
  158. been used.
  159. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
  160. Enabled: false
  161. Rails/ApplicationRecord:
  162. Exclude:
  163. - 'app/models/application_model.rb'
  164. - 'app/models/active_job_lock.rb'
  165. Rails/BulkChangeTable:
  166. Description: 'Check whether alter queries are combinable.'
  167. Enabled: false
  168. Rails/FindEach:
  169. Description: 'Prefer all.find_each over all.find.'
  170. Enabled: false
  171. Rails/HasAndBelongsToMany:
  172. Description: 'Prefer has_many :through to has_and_belongs_to_many.'
  173. # StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
  174. Enabled: false
  175. Rails/MatchRoute:
  176. Description: >-
  177. Don't use `match` to define any routes unless there is a need to map multiple request types
  178. among [:get, :post, :patch, :put, :delete] to a single action using the `:via` option.
  179. StyleGuide: 'https://rails.rubystyle.guide/#no-match-routes'
  180. Enabled: false
  181. Rails/SkipsModelValidations:
  182. Description: >-
  183. Use methods that skips model validations with caution.
  184. See reference for more information.
  185. Reference: 'http://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
  186. Enabled: true
  187. Exclude:
  188. - test/**/*
  189. - "**/*_spec.rb"
  190. - "**/*_examples.rb"
  191. Style/ClassAndModuleChildren:
  192. Description: 'Checks style of children classes and modules.'
  193. Enabled: false
  194. Naming/FileName:
  195. Description: 'Use snake_case for source file names.'
  196. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
  197. Enabled: true
  198. Exclude:
  199. - 'script/websocket-server.rb'
  200. Naming/VariableNumber:
  201. Description: 'Use the configured style when numbering variables.'
  202. Enabled: false
  203. Naming/MethodParameterName:
  204. Description: >-
  205. Checks for method parameter names that contain capital letters,
  206. end in numbers, or do not meet a minimal length.
  207. Enabled: true
  208. AllowedNames: e, id, _, ip, to
  209. Lint/BooleanSymbol:
  210. Description: 'Check for `:true` and `:false` symbols.'
  211. Enabled: true
  212. Exclude:
  213. - "db/seeds/object_manager_attributes.rb"
  214. - "spec/requests/integration/object_manager_attributes_spec.rb"
  215. - "test/integration/object_manager_test.rb"
  216. Lint/InterpolationCheck:
  217. Description: 'Raise warning for interpolation in single q strs'
  218. Enabled: true
  219. Exclude:
  220. - "test/unit/email_process_auto_response_test.rb"
  221. - "test/unit/email_process_bounce_delivery_permanent_failed_test.rb"
  222. - "test/unit/email_process_bounce_follow_test.rb"
  223. - "test/unit/notification_factory_renderer_test.rb"
  224. - "test/unit/notification_factory_template_test.rb"
  225. - "test/unit/ticket_trigger_test.rb"
  226. - "test/unit/ticket_trigger_recursive_disabled_test.rb"
  227. Style/StringConcatenation:
  228. Description: 'Checks for places where string concatenation can be replaced with string interpolation.'
  229. StyleGuide: '#string-interpolation'
  230. Enabled: true
  231. Exclude:
  232. - "config/routes/**/*"
  233. Style/RegexpLiteral:
  234. Description: 'This cop enforces using // or %r around regular expressions.'
  235. EnforcedStyle: percent_r
  236. Style/RedundantBegin:
  237. Description: 'This cop checks for redundant `begin` blocks.'
  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. # RSpec tests
  247. Style/NumericPredicate:
  248. Description: >-
  249. Checks for the use of predicate- or comparison methods for
  250. numeric comparisons.
  251. StyleGuide: '#predicate-methods'
  252. # This will change to a new method call which isn't guaranteed to be on the
  253. # object. Switching these methods has to be done with knowledge of the types
  254. # of the variables which rubocop doesn't have.
  255. AutoCorrect: false
  256. Enabled: true
  257. Exclude:
  258. - "**/*_spec.rb"
  259. Lint/AmbiguousBlockAssociation:
  260. Description: >-
  261. Checks for ambiguous block association with method when param
  262. passed without parentheses.
  263. StyleGuide: '#syntax'
  264. Enabled: true
  265. Exclude:
  266. - "spec/support/*.rb"
  267. - "**/*_spec.rb"
  268. - "**/*_examples.rb"
  269. Layout/MultilineMethodCallIndentation:
  270. Description: >-
  271. Checks the indentation of the method name part in method calls
  272. that span more than one line.
  273. EnforcedStyle: indented
  274. Include:
  275. - "**/*_spec.rb"
  276. Lint/UnusedMethodArgument:
  277. AllowUnusedKeywordArguments: true
  278. RSpec/NestedGroups:
  279. Max: 6
  280. RSpec/Rails/AvoidSetupHook:
  281. Exclude:
  282. - "test/**/*"
  283. Zammad/PreferNegatedIfOverUnless:
  284. Exclude:
  285. - 'bin/rspec'
  286. Zammad/ExistsDateTimePrecision:
  287. Include:
  288. - "db/migrate/*.rb"
  289. - "**/db/addon/**/*.rb"
  290. Zammad/ExistsResetColumnInformation:
  291. Include:
  292. - "db/migrate/*.rb"
  293. - "**/db/addon/**/*.rb"
  294. Exclude:
  295. - 'db/migrate/201*_*.rb'
  296. - 'db/migrate/2020*_*.rb'