Skip to content
Latchkey

RuboCop "offenses detected" exits 1 in CI

RuboCop exits 1 whenever it finds at least one offense. The summary "N files inspected, M offenses detected" with [Correctable] markers tells you how many are auto-fixable.

What this error means

The RuboCop step lists path:line:col: C: CopName message offenses, ends with "X files inspected, Y offenses detected", and exits 1.

RuboCop
app/models/user.rb:8:3: C: Style/StringLiterals: Prefer single-quoted strings.
  name = "alice"
         ^^^^^^^

1 file inspected, 1 offense detected, 1 offense autocorrectable

Common causes

Real style or lint offenses

RuboCop found offenses under the enabled cops, so it exits 1; this is the linting gate working as intended.

New cops after a RuboCop upgrade

A version bump enabled new cops (pending by default until configured), surfacing offenses that were not flagged before.

How to fix it

Auto-correct, then fix the rest

  1. Run rubocop -a for safe autocorrect (or -A for unsafe, reviewed).
  2. Resolve the remaining offenses by hand using the cop names.
  3. Re-run rubocop and confirm exit 0.
Terminal
bundle exec rubocop -a
bundle exec rubocop   # confirm 0 offenses

Configure a cop deliberately

Disable or adjust a noisy cop in .rubocop.yml rather than ignoring the exit code.

.rubocop.yml
# .rubocop.yml
Style/StringLiterals:
  EnforcedStyle: double_quotes

How to prevent it

  • Run RuboCop locally or in pre-commit before pushing.
  • Pin the RuboCop version and review new cops on upgrade.
  • Use NewCops: disable to opt into new cops deliberately.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →