.rubocop.yml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. require:
  2. - rubocop-rails
  3. - rubocop-rspec
  4. - rubocop-performance
  5. AllCops:
  6. TargetRubyVersion: 2.7
  7. DisplayCopNames: true
  8. DisplayStyleGuide: true
  9. ExtraDetails: true
  10. UseCache: true
  11. CacheRootDirectory: tmp
  12. NewCops: enable
  13. Exclude:
  14. - db/schema.rb
  15. - 'app/views/**/*'
  16. - 'config/**/*'
  17. - 'bin/*'
  18. - 'Rakefile'
  19. - 'node_modules/**/*'
  20. - 'Vagrantfile'
  21. - 'vendor/**/*'
  22. - 'lib/json_ld/*'
  23. - 'lib/templates/**/*'
  24. Bundler/OrderedGems:
  25. Enabled: false
  26. Layout/AccessModifierIndentation:
  27. EnforcedStyle: indent
  28. Layout/EmptyLineAfterMagicComment:
  29. Enabled: false
  30. Layout/EmptyLineAfterGuardClause:
  31. Enabled: false
  32. Layout/EmptyLineBetweenDefs:
  33. AllowAdjacentOneLineDefs: true
  34. Layout/EmptyLinesAroundAttributeAccessor:
  35. Enabled: true
  36. Layout/FirstHashElementIndentation:
  37. EnforcedStyle: consistent
  38. Layout/HashAlignment:
  39. Enabled: false
  40. Layout/SpaceAroundMethodCallOperator:
  41. Enabled: true
  42. Layout/SpaceInsideHashLiteralBraces:
  43. EnforcedStyle: space
  44. Lint/DeprecatedOpenSSLConstant:
  45. Enabled: true
  46. Lint/DuplicateElsifCondition:
  47. Enabled: true
  48. Lint/MixedRegexpCaptureTypes:
  49. Enabled: true
  50. Lint/RaiseException:
  51. Enabled: true
  52. Lint/StructNewOverride:
  53. Enabled: true
  54. Lint/UselessAccessModifier:
  55. ContextCreatingMethods:
  56. - class_methods
  57. Metrics/AbcSize:
  58. Max: 34 # RuboCop default 17
  59. Exclude:
  60. - 'lib/**/*cli*.rb'
  61. - db/*migrate/**/*
  62. - lib/paperclip/color_extractor.rb
  63. - app/workers/scheduler/follow_recommendations_scheduler.rb
  64. - app/services/activitypub/fetch*_service.rb
  65. - lib/paperclip/**/*
  66. CountRepeatedAttributes: false
  67. AllowedMethods:
  68. - update_media_attachments!
  69. - account_link_to
  70. - attempt_oembed
  71. - build_crutches
  72. - calculate_scores
  73. - cc
  74. - dump_actor!
  75. - filter_from_home?
  76. - hydrate
  77. - import_bookmarks!
  78. - import_relationships!
  79. - initialize
  80. - link_to_mention
  81. - log_target
  82. - matches_time_window?
  83. - parse_metadata
  84. - perform_statuses_search!
  85. - privatize_media_attachments!
  86. - process_update
  87. - publish_media_attachments!
  88. - remotable_attachment
  89. - render_initial_state
  90. - render_with_cache
  91. - searchable_by
  92. - self.cached_filters_for
  93. - set_fetchable_attributes!
  94. - signed_request_actor
  95. - statuses_to_delete
  96. - update_poll!
  97. Metrics/BlockLength:
  98. Max: 55
  99. Exclude:
  100. - 'lib/mastodon/*_cli.rb'
  101. CountComments: false
  102. CountAsOne: [array, heredoc]
  103. AllowedMethods:
  104. - task
  105. - namespace
  106. - class_methods
  107. - included
  108. Metrics/BlockNesting:
  109. Max: 3
  110. Exclude:
  111. - 'lib/mastodon/*_cli.rb'
  112. Metrics/ClassLength:
  113. CountComments: false
  114. Max: 500
  115. CountAsOne: [array, heredoc]
  116. Exclude:
  117. - 'lib/mastodon/*_cli.rb'
  118. Metrics/CyclomaticComplexity:
  119. Max: 12
  120. Exclude:
  121. - lib/mastodon/*cli*.rb
  122. - db/*migrate/**/*
  123. AllowedMethods:
  124. - attempt_oembed
  125. - blocked?
  126. - build_crutches
  127. - calculate_scores
  128. - cc
  129. - discover_endpoint!
  130. - filter_from_home?
  131. - hydrate
  132. - klass
  133. - link_to_mention
  134. - log_target
  135. - matches_time_window?
  136. - patch_for_forwarding!
  137. - preprocess_attributes!
  138. - process_update
  139. - remotable_attachment
  140. - scan_text!
  141. - self.cached_filters_for
  142. - set_fetchable_attributes!
  143. - setup_redis_env_url
  144. - update_media_attachments!
  145. Layout/LineLength:
  146. Max: 140 # RuboCop default 120
  147. AllowHeredoc: true
  148. AllowURI: true
  149. IgnoreCopDirectives: true
  150. AllowedPatterns:
  151. # Allow comments to be long lines
  152. - !ruby/regexp / \# .*$/
  153. - !ruby/regexp /^\# .*$/
  154. Exclude:
  155. - lib/**/*cli*.rb
  156. - db/*migrate/**/*
  157. - db/seeds/**/*
  158. Metrics/MethodLength:
  159. CountComments: false
  160. CountAsOne: [array, heredoc]
  161. Max: 25 # RuboCop default 10
  162. Exclude:
  163. - 'lib/mastodon/*_cli.rb'
  164. AllowedMethods:
  165. - account_link_to
  166. - attempt_oembed
  167. - body_with_limit
  168. - build_crutches
  169. - cached_filters_for
  170. - calculate_scores
  171. - check_webfinger!
  172. - clean_feeds!
  173. - collection_items
  174. - collection_presenter
  175. - copy_account_notes!
  176. - deduplicate_accounts!
  177. - deduplicate_conversations!
  178. - deduplicate_local_accounts!
  179. - deduplicate_statuses!
  180. - deduplicate_tags!
  181. - deduplicate_users!
  182. - discover_endpoint!
  183. - extract_extra_uris_with_indices
  184. - extract_hashtags_with_indices
  185. - extract_mentions_or_lists_with_indices
  186. - filter_from_home?
  187. - from_elasticsearch
  188. - handle_explicit_update!
  189. - handle_mark_as_sensitive!
  190. - hsl_to_rgb
  191. - import_bookmarks!
  192. - import_domain_blocks!
  193. - import_relationships!
  194. - ldap_options
  195. - matches_time_window?
  196. - outbox_presenter
  197. - pam_get_user
  198. - parallelize_with_progress
  199. - parse_and_transform
  200. - patch_for_forwarding!
  201. - populate_home
  202. - post_process_style
  203. - preload_cache_collection_target_statuses
  204. - privatize_media_attachments!
  205. - provides_callback_for
  206. - publish_media_attachments!
  207. - relevant_account_timestamp
  208. - remotable_attachment
  209. - rgb_to_hsl
  210. - rss_status_content_format
  211. - set_fetchable_attributes!
  212. - setup_redis_env_url
  213. - signed_request_actor
  214. - to_preview_card_attributes
  215. - upgrade_storage_filesystem
  216. - upgrade_storage_s3
  217. - user_settings_params
  218. - hydrate
  219. - cc
  220. - self_destruct
  221. Metrics/ModuleLength:
  222. CountComments: false
  223. Max: 200
  224. CountAsOne: [array, heredoc]
  225. Metrics/ParameterLists:
  226. Max: 5 # RuboCop default 5
  227. CountKeywordArgs: true # RuboCop default true
  228. MaxOptionalParameters: 3 # RuboCop default 3
  229. Exclude:
  230. - app/models/concerns/account_interactions.rb
  231. - app/services/activitypub/fetch_remote_account_service.rb
  232. - app/services/activitypub/fetch_remote_actor_service.rb
  233. Metrics/PerceivedComplexity:
  234. Max: 16 # RuboCop default 8
  235. AllowedMethods:
  236. - attempt_oembed
  237. - build_crutches
  238. - calculate_scores
  239. - deduplicate_users!
  240. - discover_endpoint!
  241. - filter_from_home?
  242. - hydrate
  243. - patch_for_forwarding!
  244. - process_update
  245. - remove_orphans
  246. - update_media_attachments!
  247. Naming/MemoizedInstanceVariableName:
  248. Enabled: false
  249. Naming/MethodParameterName:
  250. Enabled: true
  251. Rails:
  252. Enabled: true
  253. Rails/ApplicationController:
  254. Enabled: false
  255. Exclude:
  256. - 'app/controllers/well_known/**/*.rb'
  257. Rails/BelongsTo:
  258. Enabled: false
  259. Rails/ContentTag:
  260. Enabled: false
  261. Rails/EnumHash:
  262. Enabled: false
  263. Rails/Exit:
  264. Exclude:
  265. - 'lib/mastodon/*'
  266. - 'lib/cli.rb'
  267. Rails/FilePath:
  268. Enabled: false
  269. Rails/HasAndBelongsToMany:
  270. Enabled: false
  271. Rails/HasManyOrHasOneDependent:
  272. Enabled: false
  273. Rails/HelperInstanceVariable:
  274. Enabled: false
  275. Rails/HttpStatus:
  276. Enabled: false
  277. Rails/IndexBy:
  278. Enabled: false
  279. Rails/InverseOf:
  280. Enabled: false
  281. Rails/LexicallyScopedActionFilter:
  282. Enabled: false
  283. Rails/OutputSafety:
  284. Enabled: true
  285. Rails/RakeEnvironment:
  286. Enabled: false
  287. Rails/RedundantForeignKey:
  288. Enabled: false
  289. Rails/SkipsModelValidations:
  290. Enabled: false
  291. Rails/UniqueValidationWithoutIndex:
  292. Enabled: false
  293. Style/AccessorGrouping:
  294. Enabled: true
  295. Style/AccessModifierDeclarations:
  296. Enabled: false
  297. Style/ArrayCoercion:
  298. Enabled: true
  299. Style/BisectedAttrAccessor:
  300. Enabled: true
  301. Style/CaseLikeIf:
  302. Enabled: false
  303. Style/ClassAndModuleChildren:
  304. Enabled: false
  305. Style/CollectionMethods:
  306. Enabled: true
  307. PreferredMethods:
  308. find_all: 'select'
  309. Style/Documentation:
  310. Enabled: false
  311. Style/DoubleNegation:
  312. Enabled: true
  313. Style/ExpandPathArguments:
  314. Enabled: false
  315. Style/ExponentialNotation:
  316. Enabled: true
  317. Style/FormatString:
  318. Enabled: false
  319. Style/FormatStringToken:
  320. Enabled: false
  321. Style/FrozenStringLiteralComment:
  322. Enabled: true
  323. Style/GuardClause:
  324. Enabled: false
  325. Style/HashAsLastArrayItem:
  326. Enabled: false
  327. Style/HashEachMethods:
  328. Enabled: true
  329. Style/HashLikeCase:
  330. Enabled: true
  331. Style/HashTransformKeys:
  332. Enabled: true
  333. Style/HashTransformValues:
  334. Enabled: false
  335. Style/HashSyntax:
  336. Enabled: true
  337. EnforcedStyle: ruby19_no_mixed_keys
  338. Style/IfUnlessModifier:
  339. Enabled: false
  340. Style/InverseMethods:
  341. Enabled: false
  342. Style/Lambda:
  343. Enabled: false
  344. Style/MutableConstant:
  345. Enabled: false
  346. Style/PercentLiteralDelimiters:
  347. PreferredDelimiters:
  348. '%i': '()'
  349. '%w': '()'
  350. Style/PerlBackrefs:
  351. AutoCorrect: false
  352. Style/RedundantFetchBlock:
  353. Enabled: true
  354. Style/RedundantFileExtensionInRequire:
  355. Enabled: true
  356. Style/RedundantRegexpCharacterClass:
  357. Enabled: false
  358. Style/RedundantRegexpEscape:
  359. Enabled: false
  360. Style/RedundantReturn:
  361. Enabled: true
  362. Style/RedundantBegin:
  363. Enabled: false
  364. Style/RegexpLiteral:
  365. Enabled: false
  366. Style/RescueStandardError:
  367. Enabled: true
  368. Style/SignalException:
  369. Enabled: false
  370. Style/SlicingWithRange:
  371. Enabled: true
  372. Style/SymbolArray:
  373. Enabled: false
  374. Style/TrailingCommaInArrayLiteral:
  375. EnforcedStyleForMultiline: 'comma'
  376. Style/TrailingCommaInHashLiteral:
  377. EnforcedStyleForMultiline: 'comma'
  378. Style/UnpackFirst:
  379. Enabled: false
  380. RSpec/ScatteredSetup:
  381. Enabled: false
  382. RSpec/ImplicitExpect:
  383. Enabled: false
  384. RSpec/NamedSubject:
  385. Enabled: false
  386. RSpec/DescribeClass:
  387. Enabled: false
  388. RSpec/LetSetup:
  389. Enabled: false