Skip to content
Snippets Groups Projects
.rubocop.yml 3.48 KiB
Newer Older
inherit_from: .rubocop_todo.yml

inherit_mode:
  merge:
    - Exclude

require:
  - rubocop-rails
  - rubocop-rspec
  - rubocop-performance
Matt Jankowski's avatar
Matt Jankowski committed
AllCops:
  TargetRubyVersion: 2.7
  DisplayCopNames: true
  DisplayStyleGuide: true
  ExtraDetails: true
  UseCache: true
  CacheRootDirectory: tmp
  NewCops: enable
Matt Jankowski's avatar
Matt Jankowski committed
  Exclude:
    - db/schema.rb
    - 'config/**/*'
    - 'bin/*'
    - 'Rakefile'
    - 'node_modules/**/*'
    - 'Vagrantfile'
    - 'vendor/**/*'
    - 'lib/json_ld/*'
    - 'lib/templates/**/*'
Eugen Rochko's avatar
Eugen Rochko committed

Layout/FirstHashElementIndentation:
  EnforcedStyle: consistent

Layout/LineLength:
  Max: 140 # RuboCop default 120
  AllowedPatterns:
    # Allow comments to be long lines
    - !ruby/regexp / \# .*$/
    - !ruby/regexp /^\# .*$/
  Exclude:
    - lib/**/*cli*.rb
    - db/*migrate/**/*
    - db/seeds/**/*
abcang's avatar
abcang committed
Lint/UselessAccessModifier:
  ContextCreatingMethods:
    - class_methods

  Max: 34 # RuboCop default 17
    - 'lib/**/*cli*.rb'
    - db/*migrate/**/*
  Max: 55 # Default 25
  CountAsOne: [array, heredoc]
    - 'lib/mastodon/*_cli.rb'
  Exclude:
    - 'lib/mastodon/*_cli.rb'
  Max: 500 # Default 100
  CountAsOne: [array, heredoc]
  Exclude:
    - 'lib/mastodon/*_cli.rb'
  Max: 12 # Default 7
    - lib/mastodon/*cli*.rb
    - db/*migrate/**/*
  Max: 25 # RuboCop default 10
  CountAsOne: [array, heredoc]
  Exclude:
    - 'lib/mastodon/*_cli.rb'
  Max: 200 # Default 100
  CountAsOne: [array, heredoc]
Matt Jankowski's avatar
Matt Jankowski committed
Metrics/PerceivedComplexity:
  Max: 16 # RuboCop default 8
Rails/HttpStatus:
  EnforcedStyle: numeric

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
    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'
RSpec/NotToNot:
  EnforcedStyle: to_not

RSpec/Rails/HttpStatus:
  EnforcedStyle: numeric

Rose's avatar
Rose committed
Style/HashSyntax:
  EnforcedStyle: ruby19_no_mixed_keys

Style/NumericLiterals:
  AllowedPatterns:
    - \d{4}_\d{2}_\d{2}_\d{6} # For DB migration date version number readability

Style/PercentLiteralDelimiters:
  PreferredDelimiters:
    '%i': '()'
    '%w': '()'

Style/RescueStandardError:
  EnforcedStyle: implicit

Style/TrailingCommaInArrayLiteral:
  EnforcedStyleForMultiline: 'comma'

Style/TrailingCommaInHashLiteral:
Matt Jankowski's avatar
Matt Jankowski committed
  EnforcedStyleForMultiline: 'comma'

Style/SymbolArray:
  Enabled: false