You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
5.3 KiB

linting: RuboCop update, config fixes (#20574) * fix(rubocop): update gems and add performance and rspec fix(rubocop): update gems and add performance and rspec - update present rubocop gems - add rubocop-rspec and rubocop-performance gems - move rubocop gems to gem group :development, :test in order to make linting in a github action that runs with RAILS_ENV=test possible * feat(rubocop): disable some annoyance RSpec cops To mee these prooved to be more annoying than helpful. If not agreed, they can be enabled any time. * fix(rubocop): do not ignore spec/**/* Because rubocop-rspec should lint the specs as well, and they deserve to be readable in general. It is relevant code, after all. * fix(rubocop): change ignore db/**/* to db/schema.rb because rails cops do some lints for migrations. E.g. reversable migrations linting and more. * fix(rubocop): tune rules configs Bunch of commits squashed: fix(rubocop): enable Layout/LineLength cop Because this project has code with line lenghts > 500 chars. This is not good practice at all, so I strongly suggest to change the practice in the future. But allow heredoc, URI and comments to still be long lines and make the default Max: 120 explicit, by repeating it in the config. To me this max length seems reasonable. Perhaps a bit more could be ok for some. But > 500 chars in one line Seems to be way too long IMHO. fix(rubocop): Metrics/CyclomaticComplexity Max to 12 The default is 7, perhaps quite strict. But 25 is too loose, the rule becomes pointless like that. fix(rubocop): AllCops ruby version, cacheing and more info - fix the target ruby version from 2.5 to 3.0 - have the cop error messages to be more informative and helpful - enable cacheing in /tmp fix(rubocop): Metrics/AbcSize to 34 from 115 Rubocops default is 17. If the rule is at 115 is becomes pointless. fix(rubocop): Metrics/BlockLength improvements - instead of ignoring tasks completely, ignore only the long blocks that are specific to tasks (task, namespace) - ignore also concern specific block methods (included, class_methods) fix(rubocop): Metrics/ClassLength count heredoc array as one line fix(rubocop): Metrics/MethodLength Max to 25 - the default is 10, but 65 is too loose, so perhaps 25? fix(rubocop): Metrics/ModuleLength array and heredoc count as one fix(rubocop): Metrics/PerceivedComplexity to 16 from 25 Rubocops default is 8, so how about only doubling that, instead of > than tripple it? fix(rubocop): enable Style/RedundantAssignment Because I think that this rule would never really hurt, but improve code quality and readability. fix(rubocop): enable Style/RescueStandardError I think everyone that ever had to debug what this can bring will hopefully agree that this rule totally makes sense. In the super rare exeptions where this is totally needed, it can be excluded by disabling comment in that place. fix(rubocop): Metrics/ParameterLists add explicit defaults and some excludes
1 year ago
linting: RuboCop update, config fixes (#20574) * fix(rubocop): update gems and add performance and rspec fix(rubocop): update gems and add performance and rspec - update present rubocop gems - add rubocop-rspec and rubocop-performance gems - move rubocop gems to gem group :development, :test in order to make linting in a github action that runs with RAILS_ENV=test possible * feat(rubocop): disable some annoyance RSpec cops To mee these prooved to be more annoying than helpful. If not agreed, they can be enabled any time. * fix(rubocop): do not ignore spec/**/* Because rubocop-rspec should lint the specs as well, and they deserve to be readable in general. It is relevant code, after all. * fix(rubocop): change ignore db/**/* to db/schema.rb because rails cops do some lints for migrations. E.g. reversable migrations linting and more. * fix(rubocop): tune rules configs Bunch of commits squashed: fix(rubocop): enable Layout/LineLength cop Because this project has code with line lenghts > 500 chars. This is not good practice at all, so I strongly suggest to change the practice in the future. But allow heredoc, URI and comments to still be long lines and make the default Max: 120 explicit, by repeating it in the config. To me this max length seems reasonable. Perhaps a bit more could be ok for some. But > 500 chars in one line Seems to be way too long IMHO. fix(rubocop): Metrics/CyclomaticComplexity Max to 12 The default is 7, perhaps quite strict. But 25 is too loose, the rule becomes pointless like that. fix(rubocop): AllCops ruby version, cacheing and more info - fix the target ruby version from 2.5 to 3.0 - have the cop error messages to be more informative and helpful - enable cacheing in /tmp fix(rubocop): Metrics/AbcSize to 34 from 115 Rubocops default is 17. If the rule is at 115 is becomes pointless. fix(rubocop): Metrics/BlockLength improvements - instead of ignoring tasks completely, ignore only the long blocks that are specific to tasks (task, namespace) - ignore also concern specific block methods (included, class_methods) fix(rubocop): Metrics/ClassLength count heredoc array as one line fix(rubocop): Metrics/MethodLength Max to 25 - the default is 10, but 65 is too loose, so perhaps 25? fix(rubocop): Metrics/ModuleLength array and heredoc count as one fix(rubocop): Metrics/PerceivedComplexity to 16 from 25 Rubocops default is 8, so how about only doubling that, instead of > than tripple it? fix(rubocop): enable Style/RedundantAssignment Because I think that this rule would never really hurt, but improve code quality and readability. fix(rubocop): enable Style/RescueStandardError I think everyone that ever had to debug what this can bring will hopefully agree that this rule totally makes sense. In the super rare exeptions where this is totally needed, it can be excluded by disabling comment in that place. fix(rubocop): Metrics/ParameterLists add explicit defaults and some excludes
1 year ago
linting: RuboCop update, config fixes (#20574) * fix(rubocop): update gems and add performance and rspec fix(rubocop): update gems and add performance and rspec - update present rubocop gems - add rubocop-rspec and rubocop-performance gems - move rubocop gems to gem group :development, :test in order to make linting in a github action that runs with RAILS_ENV=test possible * feat(rubocop): disable some annoyance RSpec cops To mee these prooved to be more annoying than helpful. If not agreed, they can be enabled any time. * fix(rubocop): do not ignore spec/**/* Because rubocop-rspec should lint the specs as well, and they deserve to be readable in general. It is relevant code, after all. * fix(rubocop): change ignore db/**/* to db/schema.rb because rails cops do some lints for migrations. E.g. reversable migrations linting and more. * fix(rubocop): tune rules configs Bunch of commits squashed: fix(rubocop): enable Layout/LineLength cop Because this project has code with line lenghts > 500 chars. This is not good practice at all, so I strongly suggest to change the practice in the future. But allow heredoc, URI and comments to still be long lines and make the default Max: 120 explicit, by repeating it in the config. To me this max length seems reasonable. Perhaps a bit more could be ok for some. But > 500 chars in one line Seems to be way too long IMHO. fix(rubocop): Metrics/CyclomaticComplexity Max to 12 The default is 7, perhaps quite strict. But 25 is too loose, the rule becomes pointless like that. fix(rubocop): AllCops ruby version, cacheing and more info - fix the target ruby version from 2.5 to 3.0 - have the cop error messages to be more informative and helpful - enable cacheing in /tmp fix(rubocop): Metrics/AbcSize to 34 from 115 Rubocops default is 17. If the rule is at 115 is becomes pointless. fix(rubocop): Metrics/BlockLength improvements - instead of ignoring tasks completely, ignore only the long blocks that are specific to tasks (task, namespace) - ignore also concern specific block methods (included, class_methods) fix(rubocop): Metrics/ClassLength count heredoc array as one line fix(rubocop): Metrics/MethodLength Max to 25 - the default is 10, but 65 is too loose, so perhaps 25? fix(rubocop): Metrics/ModuleLength array and heredoc count as one fix(rubocop): Metrics/PerceivedComplexity to 16 from 25 Rubocops default is 8, so how about only doubling that, instead of > than tripple it? fix(rubocop): enable Style/RedundantAssignment Because I think that this rule would never really hurt, but improve code quality and readability. fix(rubocop): enable Style/RescueStandardError I think everyone that ever had to debug what this can bring will hopefully agree that this rule totally makes sense. In the super rare exeptions where this is totally needed, it can be excluded by disabling comment in that place. fix(rubocop): Metrics/ParameterLists add explicit defaults and some excludes
1 year ago
linting: RuboCop update, config fixes (#20574) * fix(rubocop): update gems and add performance and rspec fix(rubocop): update gems and add performance and rspec - update present rubocop gems - add rubocop-rspec and rubocop-performance gems - move rubocop gems to gem group :development, :test in order to make linting in a github action that runs with RAILS_ENV=test possible * feat(rubocop): disable some annoyance RSpec cops To mee these prooved to be more annoying than helpful. If not agreed, they can be enabled any time. * fix(rubocop): do not ignore spec/**/* Because rubocop-rspec should lint the specs as well, and they deserve to be readable in general. It is relevant code, after all. * fix(rubocop): change ignore db/**/* to db/schema.rb because rails cops do some lints for migrations. E.g. reversable migrations linting and more. * fix(rubocop): tune rules configs Bunch of commits squashed: fix(rubocop): enable Layout/LineLength cop Because this project has code with line lenghts > 500 chars. This is not good practice at all, so I strongly suggest to change the practice in the future. But allow heredoc, URI and comments to still be long lines and make the default Max: 120 explicit, by repeating it in the config. To me this max length seems reasonable. Perhaps a bit more could be ok for some. But > 500 chars in one line Seems to be way too long IMHO. fix(rubocop): Metrics/CyclomaticComplexity Max to 12 The default is 7, perhaps quite strict. But 25 is too loose, the rule becomes pointless like that. fix(rubocop): AllCops ruby version, cacheing and more info - fix the target ruby version from 2.5 to 3.0 - have the cop error messages to be more informative and helpful - enable cacheing in /tmp fix(rubocop): Metrics/AbcSize to 34 from 115 Rubocops default is 17. If the rule is at 115 is becomes pointless. fix(rubocop): Metrics/BlockLength improvements - instead of ignoring tasks completely, ignore only the long blocks that are specific to tasks (task, namespace) - ignore also concern specific block methods (included, class_methods) fix(rubocop): Metrics/ClassLength count heredoc array as one line fix(rubocop): Metrics/MethodLength Max to 25 - the default is 10, but 65 is too loose, so perhaps 25? fix(rubocop): Metrics/ModuleLength array and heredoc count as one fix(rubocop): Metrics/PerceivedComplexity to 16 from 25 Rubocops default is 8, so how about only doubling that, instead of > than tripple it? fix(rubocop): enable Style/RedundantAssignment Because I think that this rule would never really hurt, but improve code quality and readability. fix(rubocop): enable Style/RescueStandardError I think everyone that ever had to debug what this can bring will hopefully agree that this rule totally makes sense. In the super rare exeptions where this is totally needed, it can be excluded by disabling comment in that place. fix(rubocop): Metrics/ParameterLists add explicit defaults and some excludes
1 year ago
linting: RuboCop update, config fixes (#20574) * fix(rubocop): update gems and add performance and rspec fix(rubocop): update gems and add performance and rspec - update present rubocop gems - add rubocop-rspec and rubocop-performance gems - move rubocop gems to gem group :development, :test in order to make linting in a github action that runs with RAILS_ENV=test possible * feat(rubocop): disable some annoyance RSpec cops To mee these prooved to be more annoying than helpful. If not agreed, they can be enabled any time. * fix(rubocop): do not ignore spec/**/* Because rubocop-rspec should lint the specs as well, and they deserve to be readable in general. It is relevant code, after all. * fix(rubocop): change ignore db/**/* to db/schema.rb because rails cops do some lints for migrations. E.g. reversable migrations linting and more. * fix(rubocop): tune rules configs Bunch of commits squashed: fix(rubocop): enable Layout/LineLength cop Because this project has code with line lenghts > 500 chars. This is not good practice at all, so I strongly suggest to change the practice in the future. But allow heredoc, URI and comments to still be long lines and make the default Max: 120 explicit, by repeating it in the config. To me this max length seems reasonable. Perhaps a bit more could be ok for some. But > 500 chars in one line Seems to be way too long IMHO. fix(rubocop): Metrics/CyclomaticComplexity Max to 12 The default is 7, perhaps quite strict. But 25 is too loose, the rule becomes pointless like that. fix(rubocop): AllCops ruby version, cacheing and more info - fix the target ruby version from 2.5 to 3.0 - have the cop error messages to be more informative and helpful - enable cacheing in /tmp fix(rubocop): Metrics/AbcSize to 34 from 115 Rubocops default is 17. If the rule is at 115 is becomes pointless. fix(rubocop): Metrics/BlockLength improvements - instead of ignoring tasks completely, ignore only the long blocks that are specific to tasks (task, namespace) - ignore also concern specific block methods (included, class_methods) fix(rubocop): Metrics/ClassLength count heredoc array as one line fix(rubocop): Metrics/MethodLength Max to 25 - the default is 10, but 65 is too loose, so perhaps 25? fix(rubocop): Metrics/ModuleLength array and heredoc count as one fix(rubocop): Metrics/PerceivedComplexity to 16 from 25 Rubocops default is 8, so how about only doubling that, instead of > than tripple it? fix(rubocop): enable Style/RedundantAssignment Because I think that this rule would never really hurt, but improve code quality and readability. fix(rubocop): enable Style/RescueStandardError I think everyone that ever had to debug what this can bring will hopefully agree that this rule totally makes sense. In the super rare exeptions where this is totally needed, it can be excluded by disabling comment in that place. fix(rubocop): Metrics/ParameterLists add explicit defaults and some excludes
1 year ago
linting: RuboCop update, config fixes (#20574) * fix(rubocop): update gems and add performance and rspec fix(rubocop): update gems and add performance and rspec - update present rubocop gems - add rubocop-rspec and rubocop-performance gems - move rubocop gems to gem group :development, :test in order to make linting in a github action that runs with RAILS_ENV=test possible * feat(rubocop): disable some annoyance RSpec cops To mee these prooved to be more annoying than helpful. If not agreed, they can be enabled any time. * fix(rubocop): do not ignore spec/**/* Because rubocop-rspec should lint the specs as well, and they deserve to be readable in general. It is relevant code, after all. * fix(rubocop): change ignore db/**/* to db/schema.rb because rails cops do some lints for migrations. E.g. reversable migrations linting and more. * fix(rubocop): tune rules configs Bunch of commits squashed: fix(rubocop): enable Layout/LineLength cop Because this project has code with line lenghts > 500 chars. This is not good practice at all, so I strongly suggest to change the practice in the future. But allow heredoc, URI and comments to still be long lines and make the default Max: 120 explicit, by repeating it in the config. To me this max length seems reasonable. Perhaps a bit more could be ok for some. But > 500 chars in one line Seems to be way too long IMHO. fix(rubocop): Metrics/CyclomaticComplexity Max to 12 The default is 7, perhaps quite strict. But 25 is too loose, the rule becomes pointless like that. fix(rubocop): AllCops ruby version, cacheing and more info - fix the target ruby version from 2.5 to 3.0 - have the cop error messages to be more informative and helpful - enable cacheing in /tmp fix(rubocop): Metrics/AbcSize to 34 from 115 Rubocops default is 17. If the rule is at 115 is becomes pointless. fix(rubocop): Metrics/BlockLength improvements - instead of ignoring tasks completely, ignore only the long blocks that are specific to tasks (task, namespace) - ignore also concern specific block methods (included, class_methods) fix(rubocop): Metrics/ClassLength count heredoc array as one line fix(rubocop): Metrics/MethodLength Max to 25 - the default is 10, but 65 is too loose, so perhaps 25? fix(rubocop): Metrics/ModuleLength array and heredoc count as one fix(rubocop): Metrics/PerceivedComplexity to 16 from 25 Rubocops default is 8, so how about only doubling that, instead of > than tripple it? fix(rubocop): enable Style/RedundantAssignment Because I think that this rule would never really hurt, but improve code quality and readability. fix(rubocop): enable Style/RescueStandardError I think everyone that ever had to debug what this can bring will hopefully agree that this rule totally makes sense. In the super rare exeptions where this is totally needed, it can be excluded by disabling comment in that place. fix(rubocop): Metrics/ParameterLists add explicit defaults and some excludes
1 year ago
  1. inherit_from: .rubocop_todo.yml
  2. inherit_mode:
  3. merge:
  4. - Exclude
  5. require:
  6. - rubocop-rails
  7. - rubocop-rspec
  8. - rubocop-performance
  9. - rubocop-capybara
  10. AllCops:
  11. TargetRubyVersion: 2.7
  12. DisplayCopNames: true
  13. DisplayStyleGuide: true
  14. ExtraDetails: true
  15. UseCache: true
  16. CacheRootDirectory: tmp
  17. NewCops: enable
  18. Exclude:
  19. - db/schema.rb
  20. - 'bin/*'
  21. - 'Rakefile'
  22. - 'node_modules/**/*'
  23. - 'Vagrantfile'
  24. - 'vendor/**/*'
  25. - 'lib/json_ld/*'
  26. - 'lib/templates/**/*'
  27. Layout/FirstHashElementIndentation:
  28. EnforcedStyle: consistent
  29. Layout/LineLength:
  30. AllowedPatterns:
  31. # Allow comments to be long lines
  32. - !ruby/regexp / \# .*$/
  33. - !ruby/regexp /^\# .*$/
  34. Exclude:
  35. - lib/**/*cli*.rb
  36. - db/*migrate/**/*
  37. - db/seeds/**/*
  38. Lint/UselessAccessModifier:
  39. ContextCreatingMethods:
  40. - class_methods
  41. Metrics/AbcSize:
  42. Exclude:
  43. - 'lib/**/*cli*.rb'
  44. - db/*migrate/**/*
  45. Metrics/BlockLength:
  46. CountAsOne: [array, heredoc]
  47. Exclude:
  48. - 'lib/mastodon/*_cli.rb'
  49. Metrics/BlockNesting:
  50. Exclude:
  51. - 'lib/mastodon/*_cli.rb'
  52. # Reason: Some Excluded files would be candidates for refactoring but not currently addressed
  53. # https://docs.rubocop.org/rubocop/cops_metrics.html#metricsclasslength
  54. Metrics/ClassLength:
  55. CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
  56. Exclude:
  57. - 'lib/mastodon/*_cli.rb'
  58. - 'app/controllers/admin/accounts_controller.rb'
  59. - 'app/controllers/api/base_controller.rb'
  60. - 'app/controllers/api/v1/admin/accounts_controller.rb'
  61. - 'app/controllers/application_controller.rb'
  62. - 'app/controllers/auth/registrations_controller.rb'
  63. - 'app/controllers/auth/sessions_controller.rb'
  64. - 'app/lib/activitypub/activity.rb'
  65. - 'app/lib/activitypub/activity/create.rb'
  66. - 'app/lib/activitypub/tag_manager.rb'
  67. - 'app/lib/feed_manager.rb'
  68. - 'app/lib/link_details_extractor.rb'
  69. - 'app/lib/request.rb'
  70. - 'app/lib/text_formatter.rb'
  71. - 'app/lib/user_settings_decorator.rb'
  72. - 'app/mailers/user_mailer.rb'
  73. - 'app/models/account.rb'
  74. - 'app/models/admin/account_action.rb'
  75. - 'app/models/form/account_batch.rb'
  76. - 'app/models/media_attachment.rb'
  77. - 'app/models/status.rb'
  78. - 'app/models/tag.rb'
  79. - 'app/models/user.rb'
  80. - 'app/serializers/activitypub/actor_serializer.rb'
  81. - 'app/serializers/activitypub/note_serializer.rb'
  82. - 'app/serializers/rest/status_serializer.rb'
  83. - 'app/services/account_search_service.rb'
  84. - 'app/services/activitypub/process_account_service.rb'
  85. - 'app/services/activitypub/process_status_update_service.rb'
  86. - 'app/services/backup_service.rb'
  87. - 'app/services/delete_account_service.rb'
  88. - 'app/services/fan_out_on_write_service.rb'
  89. - 'app/services/fetch_link_card_service.rb'
  90. - 'app/services/import_service.rb'
  91. - 'app/services/notify_service.rb'
  92. - 'app/services/post_status_service.rb'
  93. - 'app/services/update_status_service.rb'
  94. - 'lib/paperclip/color_extractor.rb'
  95. Metrics/CyclomaticComplexity:
  96. Exclude:
  97. - lib/mastodon/*cli*.rb
  98. - db/*migrate/**/*
  99. Metrics/MethodLength:
  100. CountAsOne: [array, heredoc]
  101. Exclude:
  102. - 'lib/mastodon/*_cli.rb'
  103. Metrics/ModuleLength:
  104. CountAsOne: [array, heredoc]
  105. Rails/HttpStatus:
  106. EnforcedStyle: numeric
  107. Rails/Exit:
  108. Exclude:
  109. - 'lib/mastodon/*_cli.rb'
  110. - 'lib/mastodon/cli_helper.rb'
  111. - 'lib/cli.rb'
  112. # Reason: Some single letter camel case files shouldn't be split
  113. # https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecfilepath
  114. RSpec/FilePath:
  115. CustomTransform:
  116. ActivityPub: activitypub # Ignore the snake_case due to the amount of files to rename
  117. DeepL: deepl
  118. FetchOEmbedService: fetch_oembed_service
  119. JsonLdHelper: jsonld_helper
  120. OEmbedController: oembed_controller
  121. OStatus: ostatus
  122. NodeInfoController: nodeinfo_controller # NodeInfo isn't snake_cased for any of the instances
  123. Exclude:
  124. - 'spec/config/initializers/rack_attack_spec.rb' # namespaces usually have separate folder
  125. - 'spec/lib/sanitize_config_spec.rb' # namespaces usually have separate folder
  126. - 'spec/controllers/concerns/account_controller_concern_spec.rb' # Concerns describe ApplicationController and don't fit naming
  127. - 'spec/controllers/concerns/export_controller_concern_spec.rb'
  128. - 'spec/controllers/concerns/localized_spec.rb'
  129. - 'spec/controllers/concerns/rate_limit_headers_spec.rb'
  130. - 'spec/controllers/concerns/signature_verification_spec.rb'
  131. - 'spec/controllers/concerns/user_tracking_concern_spec.rb'
  132. RSpec/NotToNot:
  133. EnforcedStyle: to_not
  134. RSpec/Rails/HttpStatus:
  135. EnforcedStyle: numeric
  136. # Reason:
  137. # https://docs.rubocop.org/rubocop/cops_style.html#styleclassandmodulechildren
  138. Style/ClassAndModuleChildren:
  139. Enabled: false
  140. # Reason: Classes mostly self-document with their names
  141. # https://docs.rubocop.org/rubocop/cops_style.html#styledocumentation
  142. Style/Documentation:
  143. Enabled: false
  144. Style/HashSyntax:
  145. EnforcedStyle: ruby19_no_mixed_keys
  146. Style/NumericLiterals:
  147. AllowedPatterns:
  148. - \d{4}_\d{2}_\d{2}_\d{6} # For DB migration date version number readability
  149. Style/PercentLiteralDelimiters:
  150. PreferredDelimiters:
  151. '%i': '()'
  152. '%w': '()'
  153. Style/RescueStandardError:
  154. EnforcedStyle: implicit
  155. Style/TrailingCommaInArrayLiteral:
  156. EnforcedStyleForMultiline: 'comma'
  157. Style/TrailingCommaInHashLiteral:
  158. EnforcedStyleForMultiline: 'comma'
  159. Style/SymbolArray:
  160. Enabled: false