mirror of https://github.com/mastodon/mastodon.git
265 lines
9.2 KiB
YAML
265 lines
9.2 KiB
YAML
# Can be removed once all rules are addressed or moved to this file as documented overrides
|
|
inherit_from: .rubocop_todo.yml
|
|
|
|
# Used for merging with exclude lists with .rubocop_todo.yml
|
|
inherit_mode:
|
|
merge:
|
|
- Exclude
|
|
|
|
require:
|
|
- rubocop-rails
|
|
- rubocop-rspec
|
|
- rubocop-performance
|
|
- rubocop-capybara
|
|
|
|
AllCops:
|
|
TargetRubyVersion: 3.0 # Set to minimum supported version of CI
|
|
DisplayCopNames: true
|
|
DisplayStyleGuide: true
|
|
ExtraDetails: true
|
|
UseCache: true
|
|
CacheRootDirectory: tmp
|
|
NewCops: enable # Opt-in to newly added rules
|
|
Exclude:
|
|
- db/schema.rb
|
|
- 'bin/*'
|
|
- 'Rakefile'
|
|
- 'node_modules/**/*'
|
|
- 'Vagrantfile'
|
|
- 'vendor/**/*'
|
|
- 'lib/json_ld/*' # Generated files
|
|
- 'lib/templates/**/*'
|
|
|
|
# Reason: Prefer Hashes without extreme indentation
|
|
# https://docs.rubocop.org/rubocop/cops_layout.html#layoutfirsthashelementindentation
|
|
Layout/FirstHashElementIndentation:
|
|
EnforcedStyle: consistent
|
|
|
|
# Reason: Currently disabled in .rubocop_todo.yml
|
|
# https://docs.rubocop.org/rubocop/cops_layout.html#layoutlinelength
|
|
Layout/LineLength:
|
|
AllowedPatterns:
|
|
# Allow comments to be long lines
|
|
- !ruby/regexp / \# .*$/
|
|
- !ruby/regexp /^\# .*$/
|
|
Exclude:
|
|
- lib/**/*cli*.rb
|
|
- db/*migrate/**/*
|
|
- db/seeds/**/*
|
|
|
|
# Reason:
|
|
# https://docs.rubocop.org/rubocop/cops_lint.html#lintuselessaccessmodifier
|
|
Lint/UselessAccessModifier:
|
|
ContextCreatingMethods:
|
|
- class_methods
|
|
|
|
# Reason: Currently disabled in .rubocop_todo.yml
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsabcsize
|
|
Metrics/AbcSize:
|
|
Exclude:
|
|
- 'lib/**/*cli*.rb'
|
|
- db/*migrate/**/*
|
|
|
|
# Reason: Some functions cannot be broken up, but others may be refactor candidates
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsblocklength
|
|
Metrics/BlockLength:
|
|
CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
|
|
Exclude:
|
|
- 'config/routes.rb'
|
|
- 'lib/mastodon/*_cli.rb'
|
|
- 'lib/tasks/*.rake'
|
|
- 'app/models/concerns/account_associations.rb'
|
|
- 'app/models/concerns/account_interactions.rb'
|
|
- 'app/models/concerns/ldap_authenticable.rb'
|
|
- 'app/models/concerns/omniauthable.rb'
|
|
- 'app/models/concerns/pam_authenticable.rb'
|
|
- 'app/models/concerns/remotable.rb'
|
|
- 'app/services/suspend_account_service.rb'
|
|
- 'app/services/unsuspend_account_service.rb'
|
|
- 'app/views/accounts/show.rss.ruby'
|
|
- 'app/views/tags/show.rss.ruby'
|
|
- 'config/environments/development.rb'
|
|
- 'config/environments/production.rb'
|
|
- 'config/initializers/devise.rb'
|
|
- 'config/initializers/doorkeeper.rb'
|
|
- 'config/initializers/omniauth.rb'
|
|
- 'config/initializers/simple_form.rb'
|
|
- 'config/navigation.rb'
|
|
- 'config/routes.rb'
|
|
- 'config/routes/*.rb'
|
|
- 'db/post_migrate/20221101190723_backfill_admin_action_logs.rb'
|
|
- 'db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb'
|
|
- 'lib/paperclip/gif_transcoder.rb'
|
|
|
|
# Reason:
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsblocknesting
|
|
Metrics/BlockNesting:
|
|
Exclude:
|
|
- 'lib/mastodon/*_cli.rb'
|
|
|
|
# Reason: Some Excluded files would be candidates for refactoring but not currently addressed
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsclasslength
|
|
Metrics/ClassLength:
|
|
CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
|
|
Exclude:
|
|
- 'lib/mastodon/*_cli.rb'
|
|
- 'app/controllers/admin/accounts_controller.rb'
|
|
- 'app/controllers/api/base_controller.rb'
|
|
- 'app/controllers/api/v1/admin/accounts_controller.rb'
|
|
- 'app/controllers/application_controller.rb'
|
|
- 'app/controllers/auth/registrations_controller.rb'
|
|
- 'app/controllers/auth/sessions_controller.rb'
|
|
- 'app/lib/activitypub/activity.rb'
|
|
- 'app/lib/activitypub/activity/create.rb'
|
|
- 'app/lib/activitypub/tag_manager.rb'
|
|
- 'app/lib/feed_manager.rb'
|
|
- 'app/lib/link_details_extractor.rb'
|
|
- 'app/lib/request.rb'
|
|
- 'app/lib/text_formatter.rb'
|
|
- 'app/lib/user_settings_decorator.rb'
|
|
- 'app/mailers/user_mailer.rb'
|
|
- 'app/models/account.rb'
|
|
- 'app/models/admin/account_action.rb'
|
|
- 'app/models/form/account_batch.rb'
|
|
- 'app/models/media_attachment.rb'
|
|
- 'app/models/status.rb'
|
|
- 'app/models/tag.rb'
|
|
- 'app/models/user.rb'
|
|
- 'app/serializers/activitypub/actor_serializer.rb'
|
|
- 'app/serializers/activitypub/note_serializer.rb'
|
|
- 'app/serializers/rest/status_serializer.rb'
|
|
- 'app/services/account_search_service.rb'
|
|
- 'app/services/activitypub/process_account_service.rb'
|
|
- 'app/services/activitypub/process_status_update_service.rb'
|
|
- 'app/services/backup_service.rb'
|
|
- 'app/services/bulk_import_service.rb'
|
|
- 'app/services/delete_account_service.rb'
|
|
- 'app/services/fan_out_on_write_service.rb'
|
|
- 'app/services/fetch_link_card_service.rb'
|
|
- 'app/services/import_service.rb'
|
|
- 'app/services/notify_service.rb'
|
|
- 'app/services/post_status_service.rb'
|
|
- 'app/services/update_status_service.rb'
|
|
- 'lib/paperclip/color_extractor.rb'
|
|
|
|
# Reason: Currently disabled in .rubocop_todo.yml
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricscyclomaticcomplexity
|
|
Metrics/CyclomaticComplexity:
|
|
Exclude:
|
|
- lib/mastodon/*cli*.rb
|
|
- db/*migrate/**/*
|
|
|
|
# Reason: Currently disabled in .rubocop_todo.yml
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsmethodlength
|
|
Metrics/MethodLength:
|
|
CountAsOne: [array, heredoc]
|
|
Exclude:
|
|
- 'lib/mastodon/*_cli.rb'
|
|
|
|
# Reason:
|
|
# https://docs.rubocop.org/rubocop/cops_style.html#stylerescuestandarderror
|
|
Metrics/ModuleLength:
|
|
CountAsOne: [array, heredoc]
|
|
|
|
# Reason: Prevailing style uses numeric status codes, matches RSpec/Rails/HttpStatus
|
|
# https://docs.rubocop.org/rubocop-rails/cops_rails.html#railshttpstatus
|
|
Rails/HttpStatus:
|
|
EnforcedStyle: numeric
|
|
|
|
# Reason: Allowed only in the `tootctl` CLI application code
|
|
# https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsexit
|
|
Rails/Exit:
|
|
Exclude:
|
|
- 'lib/mastodon/*_cli.rb'
|
|
- 'lib/mastodon/cli_helper.rb'
|
|
- 'lib/cli.rb'
|
|
|
|
# Reason: Some single letter camel case files shouldn't be split
|
|
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecfilepath
|
|
RSpec/FilePath:
|
|
CustomTransform:
|
|
ActivityPub: activitypub # Ignore the snake_case due to the amount of files to rename
|
|
DeepL: deepl
|
|
FetchOEmbedService: fetch_oembed_service
|
|
JsonLdHelper: jsonld_helper
|
|
OEmbedController: oembed_controller
|
|
OStatus: ostatus
|
|
NodeInfoController: nodeinfo_controller # NodeInfo isn't snake_cased for any of the instances
|
|
Exclude:
|
|
- 'spec/config/initializers/rack_attack_spec.rb' # namespaces usually have separate folder
|
|
- 'spec/lib/sanitize_config_spec.rb' # namespaces usually have separate folder
|
|
- 'spec/controllers/concerns/account_controller_concern_spec.rb' # Concerns describe ApplicationController and don't fit naming
|
|
- 'spec/controllers/concerns/export_controller_concern_spec.rb'
|
|
- 'spec/controllers/concerns/localized_spec.rb'
|
|
- 'spec/controllers/concerns/rate_limit_headers_spec.rb'
|
|
- 'spec/controllers/concerns/signature_verification_spec.rb'
|
|
- 'spec/controllers/concerns/user_tracking_concern_spec.rb'
|
|
|
|
# Reason:
|
|
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecnamedsubject
|
|
RSpec/NamedSubject:
|
|
EnforcedStyle: named_only
|
|
|
|
# Reason: Prevailing style choice
|
|
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecnottonot
|
|
RSpec/NotToNot:
|
|
EnforcedStyle: to_not
|
|
|
|
# Reason: Prevailing style uses numeric status codes, matches Rails/HttpStatus
|
|
# https://docs.rubocop.org/rubocop-rspec/cops_rspec_rails.html#rspecrailshttpstatus
|
|
RSpec/Rails/HttpStatus:
|
|
EnforcedStyle: numeric
|
|
|
|
# Reason:
|
|
# https://docs.rubocop.org/rubocop/cops_style.html#styleclassandmodulechildren
|
|
Style/ClassAndModuleChildren:
|
|
Enabled: false
|
|
|
|
# Reason: Classes mostly self-document with their names
|
|
# https://docs.rubocop.org/rubocop/cops_style.html#styledocumentation
|
|
Style/Documentation:
|
|
Enabled: false
|
|
|
|
# Reason: Enforce modern Ruby style
|
|
# https://docs.rubocop.org/rubocop/cops_style.html#stylehashsyntax
|
|
Style/HashSyntax:
|
|
EnforcedStyle: ruby19_no_mixed_keys
|
|
|
|
# Reason:
|
|
# https://docs.rubocop.org/rubocop/cops_style.html#stylenumericliterals
|
|
Style/NumericLiterals:
|
|
AllowedPatterns:
|
|
- \d{4}_\d{2}_\d{2}_\d{6} # For DB migration date version number readability
|
|
|
|
# Reason:
|
|
# https://docs.rubocop.org/rubocop/cops_style.html#stylepercentliteraldelimiters
|
|
Style/PercentLiteralDelimiters:
|
|
PreferredDelimiters:
|
|
'%i': '()'
|
|
'%w': '()'
|
|
|
|
# Reason: Prefer less indentation in conditional assignments
|
|
# https://docs.rubocop.org/rubocop/cops_style.html#styleredundantbegin
|
|
Style/RedundantBegin:
|
|
Enabled: false
|
|
|
|
# Reason: Overridden to reduce implicit StandardError rescues
|
|
# https://docs.rubocop.org/rubocop/cops_style.html#stylerescuestandarderror
|
|
Style/RescueStandardError:
|
|
EnforcedStyle: implicit
|
|
|
|
# Reason: Originally disabled for CodeClimate, and no config consensus has been found
|
|
# https://docs.rubocop.org/rubocop/cops_style.html#stylesymbolarray
|
|
Style/SymbolArray:
|
|
Enabled: false
|
|
|
|
# Reason:
|
|
# https://docs.rubocop.org/rubocop/cops_style.html#styletrailingcommainarrayliteral
|
|
Style/TrailingCommaInArrayLiteral:
|
|
EnforcedStyleForMultiline: 'comma'
|
|
|
|
# Reason:
|
|
# https://docs.rubocop.org/rubocop/cops_style.html#styletrailingcommainhashliteral
|
|
Style/TrailingCommaInHashLiteral:
|
|
EnforcedStyleForMultiline: 'comma'
|