Skip to content
Snippets Groups Projects
.rubocop.yml 9.21 KiB
# 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'