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 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.
Terminal
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
# .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.
Related guides
RuboCop "Unnecessary disabling" (RedundantCopDisableDirective) in CIFix RuboCop "Unnecessary disabling of X" (Lint/RedundantCopDisableDirective) in CI - a rubocop:disable commen…
RuboCop cannot load .rubocop.yml (unrecognized cop) in CIFix RuboCop config load failures in CI - an unrecognized cop, a missing required extension, or a bad inherit_…
ESLint "Command failed with exit code 1" on lint errors in CIFix ESLint exiting with code 1 in CI - ESLint returns a non-zero exit when any error-level rule is violated,…