Skip to content
Latchkey

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.

rspec
Inspecting 142 files
....C....

app/models/user.rb:18:7: C: Style/StringLiterals:
Prefer single-quoted strings.
142 files inspected, 3 offenses detected

Common 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

  1. Run bundle exec rubocop -A to autocorrect safe offenses, then review and commit.
  2. Pin RuboCop (and extensions) in the Gemfile so local and CI agree.
  3. Regenerate .rubocop_todo.yml if you are adopting cops incrementally.
Terminal
bundle exec rubocop -A
bundle exec rubocop --regenerate-todo   # if using a todo file

How 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.

Frequently asked questions

What causes ""RuboCop offenses""?
Code introduced offenses the configured cops flag, and CI requires zero offenses.
How do I fix "RuboCop offenses"?
Autocorrect and align versions

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card