mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-21 00:29:47 +00:00
203 lines
6.3 KiB
YAML
203 lines
6.3 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
|
|
- ./lib/linter/rubocop_middle_dot
|
|
|
|
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/*'
|
|
- '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:
|
|
Max: 320 # Default of 120 causes a duplicate entry in generated todo file
|
|
|
|
# Reason:
|
|
# https://docs.rubocop.org/rubocop/cops_lint.html#lintuselessaccessmodifier
|
|
Lint/UselessAccessModifier:
|
|
ContextCreatingMethods:
|
|
- class_methods
|
|
|
|
## Disable most Metrics/*Length cops
|
|
# Reason: those are often triggered and force significant refactors when this happend
|
|
# but the team feel they are not really improving the code quality.
|
|
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsblocklength
|
|
Metrics/BlockLength:
|
|
Enabled: false
|
|
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsclasslength
|
|
Metrics/ClassLength:
|
|
Enabled: false
|
|
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsmethodlength
|
|
Metrics/MethodLength:
|
|
Enabled: false
|
|
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsmodulelength
|
|
Metrics/ModuleLength:
|
|
Enabled: false
|
|
|
|
## End Disable Metrics/*Length cops
|
|
|
|
# Reason: Currently disabled in .rubocop_todo.yml
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsabcsize
|
|
Metrics/AbcSize:
|
|
Exclude:
|
|
- 'lib/mastodon/cli/*.rb'
|
|
- db/*migrate/**/*
|
|
|
|
# Reason:
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsblocknesting
|
|
Metrics/BlockNesting:
|
|
Exclude:
|
|
- 'lib/mastodon/cli/*.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:
|
|
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsparameterlists
|
|
Metrics/ParameterLists:
|
|
CountKeywordArgs: false
|
|
|
|
# Reason: Prevailing style is argument file paths
|
|
# https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsfilepath
|
|
Rails/FilePath:
|
|
EnforcedStyle: arguments
|
|
|
|
# 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 in `tootctl` CLI code and in boot ENV checker
|
|
# https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsexit
|
|
Rails/Exit:
|
|
Exclude:
|
|
- 'config/boot.rb'
|
|
- 'lib/mastodon/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
|
|
|
|
# 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: Simplify some spec layouts
|
|
# https://docs.rubocop.org/rubocop/cops_style.html#stylesemicolon
|
|
Style/Semicolon:
|
|
AllowAsExpressionSeparator: true
|
|
|
|
# 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'
|
|
|
|
Style/MiddleDot:
|
|
Enabled: true
|