Skip to content
Latchkey

rubocop .rubocop.yml Configuration

rubocop is configured by .rubocop.yml, where AllCops sets global options and each cop can be enabled, disabled, or tuned.

The config decides which cops run, the target Ruby, and which paths are scanned. It can inherit from gems, files, or remote URLs.

What it does

rubocop reads .rubocop.yml from the project root (and merges parent directories). AllCops holds global settings like TargetRubyVersion and NewCops; per-cop blocks set Enabled, Max, Exclude, and similar. inherit_from and inherit_gem pull in shared config.

Common usage

.rubocop.yml
AllCops:
  TargetRubyVersion: 3.2
  NewCops: enable
  Exclude:
    - "db/schema.rb"
    - "vendor/**/*"
Metrics/MethodLength:
  Max: 20
Style/Documentation:
  Enabled: false

Config keys

KeyWhat it does
AllCops/TargetRubyVersionRuby version cops target
AllCops/NewCopsenable / disable cops added in newer versions
AllCops/ExcludePaths RuboCop ignores entirely
<Cop>/EnabledTurn a specific cop on or off
inherit_fromMerge another YAML config (e.g. the todo file)
inherit_gemPull config shipped inside a gem

Common errors in CI

"X has the wrong namespace - should be Y" means a cop moved departments in an upgrade; update the key. "obsolete parameter ... (for X) found" means a renamed setting. Setting NewCops: enable makes upgrades surface new cops as failures, so pin the rubocop version and review NewCops on each bump.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →