default.yml 10 KB

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