Configure RuboCop in RubyMine for Real-Time Style Enforcement and Auto-Correction
Step‑by‑step guide to enabling RuboCop in RubyMine: add the gem, turn on the inspection, use quick‑fixes and batch auto‑correction, create a CI‑matching run configuration, tune performance, and verify the setup with a practical checklist.
12 Apr 2026, 11:20 UTC

Outcome
Enable RubyMine's built-in RuboCop integration so that style violations appear as you type, quick‑fixes resolve common offenses with a keystroke, and full‑project scans match your CI pipeline. This guide assumes RubyMine 2024.1+ on macOS, Linux, or Windows with a Ruby project managed by Bundler.
Prerequisites
- RubyMine with the Ruby plugin enabled (bundled by default).
- A Ruby project containing a
GemfileandGemfile.lock. - Bundler installed (
gem install bundler). - Project Ruby version matches the RuboCop version you intend to use (see version compatibility note below).
Add RuboCop to the Project
Open the project's Gemfile and add RuboCop to the development group (and test if you run it in CI). Include any extensions your stack needs, such as rubocop-rails or rubocop-rspec.
group :development, :test do
gem 'rubocop', require: false
gem 'rubocop-rails', require: false
gem 'rubocop-rspec', require: false
end
Run bundle install from the project root (terminal or RubyMine's Tools > Bundler > Install). Verify the gem is present with bundle exec rubocop --version.
Enable RuboCop Inspection in RubyMine
- Open Settings (Ctrl+Alt+S / ⌘,).
- Navigate to Editor > Inspections.
- In the search box, type RuboCop.
- Check the RuboCop entry under Ruby.
- Optionally adjust the severity (default Warning) and scope (default Project files).
- Click Apply and OK.
RubyMine will start the RuboCop daemon using the project's Bundler environment. The first run may take several seconds on large codebases.
Verify Real-Time Highlighting
Open any Ruby file and introduce a deliberate violation—for example, remove the # frozen_string_literal: true comment from the top of a file. You should see:
- A colored underline (default yellow for warnings) on the first line.
- A gutter marker with the RuboCop icon.
- Hover text showing the offense code (e.g.,
Style/FrozenStringLiteralComment).
If nothing appears, open the Problems tool window (Alt+6) and check the RuboCop tab for startup errors such as missing gems or version mismatches.
Use Quick-Fixes for Single Offenses
Place the caret on a highlighted line and press Alt+Enter (or ⌥⏎). The intention menu shows RuboCop: Auto-correct when a safe auto‑correction exists. Select it to apply the fix instantly. For offenses without safe auto‑correction, the menu offers RuboCop: Disable this rule for this file which inserts a # rubocop:disable comment.
Run Batch Auto-Correction Across the Project
For larger cleanups, use the full inspection runner:
- Choose Code > Inspect Code….
- In the dialog, select Custom scope > Project Files (or a narrower scope).
- Under Inspection profile, choose Project Default (which now includes RuboCop).
- Click OK. Results appear in the Inspection Results tool window.
- Right-click the RuboCop node > Apply fixes (or press Ctrl+Alt+Shift+A).
Risk: Auto‑correction can change semantics (e.g., converting double quotes to single quotes may affect interpolation). Review all changes in the Git tool window (Alt+9) before committing.
Create a Dedicated RuboCop Run Configuration
Mirror your CI command for consistent local validation:
- Open Run > Edit Configurations….
- Click + > RuboCop.
- Name it (e.g.,
RuboCop (full)). - Set Command to
rubocop(runs viabundle execautomatically). - Optionally add Arguments like
--parallelor--format progress. - Set Working directory to
$ProjectFileDir$. - Click OK.
Run it from the toolbar or Shift+F10. Output appears in the Run tool window with clickable file:line links.
Configure Rules via .rubocop.yml
Place a .rubocop.yml in the project root. RubyMine watches this file and reloads rules within a few seconds (or after File > Invalidate Caches > Restart if stale). Example snippet:
inherit_mode:
merge:
- Exclude
AllCops:
TargetRubyVersion: 3.2
NewCops: enable
Exclude:
- 'db/schema.rb'
- 'bin/*'
- 'vendor/**/*'
Style/FrozenStringLiteralComment:
Enabled: true
Metrics/BlockLength:
Exclude:
- 'spec/**/*'
- 'config/routes.rb'
After saving, open a file that previously violated Style/FrozenStringLiteralComment—the highlight should disappear without restarting the editor.
Performance Tuning for Large Codebases
- Scope restriction: In Settings > Editor > Inspections > RuboCop, change Scope from Project files to a custom scope excluding
vendor/,tmp/, or generated code. - Disable real‑time, keep batch: Uncheck the RuboCop inspection entirely, then rely on the dedicated run configuration or a pre‑commit hook for enforcement.
- Parallel RuboCop: Add
--parallelto the run configuration arguments; RubyMine's inspection runner does not yet parallelize, but the CLI does.
Version Compatibility and Troubleshooting
| Symptom | Likely Cause | Resolution |
|---|---|---|
| Inspection shows "RuboCop not found" | Gem missing from Gemfile.lock or wrong Bundler environment | Run bundle install; ensure RubyMine uses the project SDK (File > Project Structure > SDK) |
| False positives on new syntax | RuboCop version older than project Ruby version | Update gem 'rubocop', '~> 1.60' in Gemfile and bundle update rubocop |
| Extensions rules not recognized | rubocop-rails / rubocop-rspec not in Gemfile | Add gems, bundle install, restart RubyMine |
| High CPU after enabling | Daemon scanning entire project on every keystroke | Narrow inspection scope or disable real‑time (see Performance Tuning) |
Verification Checklist
- Open a file with a known violation (missing frozen string literal). Confirm gutter marker and underline appear within 2 seconds.
- Press Alt+Enter on the violation; select RuboCop: Auto-correct. Verify the comment is inserted and highlight clears.
- Run Code > Inspect Code with the RuboCop profile. Confirm the results list matches
bundle exec rubocopoutput. - Edit
.rubocop.ymlto disable a rule (e.g.,Style/StringLiterals: Enabled: false). Save, wait 5 seconds, and verify the corresponding highlights vanish. - Run the dedicated RuboCop run configuration. Exit code 0 should appear for a clean project; non‑zero with clickable offenses otherwise.
Rollback / Recovery
If auto-correction introduces regressions:
- Use Git > Undo Commit or Local History > Revert on affected files.
- To disable RuboCop entirely: uncheck the inspection in Settings > Editor > Inspections and remove the run configuration.
Limitations
- RubyMine's inspection runner does not yet support
--parallel; full-project scans are single-threaded. - Custom RuboCop formatters (e.g., JSON for CI) are not consumed by the IDE; use the CLI run configuration for those outputs.
- Daemon restart is required after changing the project SDK or Bundler gemset; use File > Invalidate Caches > Restart.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.