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.
app/models/user.rb:8:3: C: Style/StringLiterals: Prefer single-quoted strings.
name = "alice"
^^^^^^^
1 file inspected, 1 offense detected, 1 offense autocorrectableCommon 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
- Run
rubocop -afor safe autocorrect (or-Afor unsafe, reviewed). - Resolve the remaining offenses by hand using the cop names.
- Re-run
rubocopand confirm exit 0.
bundle exec rubocop -a
bundle exec rubocop # confirm 0 offensesConfigure a cop deliberately
Disable or adjust a noisy cop in .rubocop.yml rather than ignoring the exit code.
# .rubocop.yml
Style/StringLiterals:
EnforcedStyle: double_quotesHow to prevent it
- Run RuboCop locally or in pre-commit before pushing.
- Pin the RuboCop version and review new cops on upgrade.
- Use
NewCops: disableto opt into new cops deliberately.