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
AllCops:
TargetRubyVersion: 3.2
NewCops: enable
Exclude:
- "db/schema.rb"
- "vendor/**/*"
Metrics/MethodLength:
Max: 20
Style/Documentation:
Enabled: falseConfig keys
| Key | What it does |
|---|---|
| AllCops/TargetRubyVersion | Ruby version cops target |
| AllCops/NewCops | enable / disable cops added in newer versions |
| AllCops/Exclude | Paths RuboCop ignores entirely |
| <Cop>/Enabled | Turn a specific cop on or off |
| inherit_from | Merge another YAML config (e.g. the todo file) |
| inherit_gem | Pull 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.