RuboCop offenses failing CI
RuboCop found offenses and exited non-zero, failing the job. The offenses are real (or the config differs from local), and CI gates on a clean lint run.
What this error means
The lint step ends with a count of detected offenses and exits 1. Often it passes locally because of a different RuboCop version, a stale .rubocop_todo.yml, or uncommitted config.
Inspecting 142 files
....C....
app/models/user.rb:18:7: C: Style/StringLiterals:
Prefer single-quoted strings.
142 files inspected, 3 offenses detectedCommon causes
Real style/lint violations
Code introduced offenses the configured cops flag, and CI requires zero offenses.
RuboCop version drift
CI runs a different RuboCop version than local (cops added/changed), so new offenses appear only in CI.
Stale or uncommitted config
.rubocop.yml or .rubocop_todo.yml differs between local and CI, changing which offenses fire.
How to fix it
Autocorrect and align versions
- Run bundle exec rubocop -A to autocorrect safe offenses, then review and commit.
- Pin RuboCop (and extensions) in the Gemfile so local and CI agree.
- Regenerate .rubocop_todo.yml if you are adopting cops incrementally.
bundle exec rubocop -A
bundle exec rubocop --regenerate-todo # if using a todo fileHow to prevent it
- Pin RuboCop and its plugins so CI matches local.
- Run RuboCop as a pre-commit/pre-push hook.
- Keep .rubocop.yml and the todo file committed and current.