Catch Ruby Style Violations Before Commit with RubyMine's RuboCop Integration
RubyMine's built-in RuboCop integration highlights style offenses in-editor and offers auto-correct quick-fixes using your project's rubocop.yml. Configure inspections to match team rules, fix violations before commit, and reduce PR churn over formatting nits.
17 Oct 2025, 08:26 UTC

The problem: style drift slows down reviews
Every Ruby team agrees on a style guide. Few teams enforce it consistently before code reaches a pull request. The result: reviewers spend cycles flagging trailing commas, line-length violations, and inconsistent quoting instead of discussing logic. RubyMine's built-in RuboCop integration puts those checks directly in the editor so you fix them while you type — not after CI fails.
How RubyMine surfaces RuboCop offenses
When you open a Ruby file, RubyMine runs RuboCop inspections in the background using the project's rubocop.yml. Offenses appear as colored squiggles in the editor gutter and as entries in the Problems tool window (Alt+6 on Windows/Linux, ⌘6 on macOS). Each entry shows the cop name (e.g., Layout/LineLength), the severity, and a quick-fix action when RuboCop can auto-correct it.
This works out of the box if:
- RuboCop is installed in the project's Ruby interpreter (via
bundle installorgem install rubocop). - A
rubocop.ymlexists in the project root or a parent directory. - The inspection is enabled at Settings > Editor > Inspections > Ruby > RuboCop.
Align inspections with your team's agreed rules
RubyMine reads rubocop.yml automatically, so the IDE enforces exactly what your team committed — not JetBrains defaults. You can still override severity per cop in the Inspections dialog: promote a warning to an error, or downgrade a noisy cop to a weak warning. Changes here are stored in .idea/inspectionProfiles/Project_Default.xml and can be shared via version control if the whole team uses RubyMine.
# Example rubocop.yml snippet
Layout/LineLength:
Max: 100
Enabled: true
Style/StringLiterals:
EnforcedStyle: double_quotes
Enabled: true
After editing rubocop.yml, click the Reload button in the Inspections dialog or restart RubyMine to pick up changes.
Worked example: fixing a violation without leaving the editor
Suppose you add a method that exceeds the configured line length:
def generate_report(user, include_archived: false, include_drafts: false, format: :pdf)
# ... implementation
end
RubyMine underlines the method signature with a wavy yellow line. Hovering shows:
RuboCop: Layout/LineLength — Line is too long. [112/100]
Press Alt+Enter (⌥⏎ on macOS) on the line. The quick-fix menu includes RuboCop: Auto-correct. Selecting it rewrites the method to:
def generate_report(user,
include_archived: false,
include_drafts: false,
format: :pdf)
# ... implementation
end
The offense disappears. You can also right-click the file tab and choose RuboCop > Auto-correct all offenses in file to batch-fix.
Trade-offs and limitations
- Auto-correct can reformat unexpectedly. Review the diff (Ctrl+D / ⌘D) before committing, especially on shared branches. Some cops (e.g.,
Style/BlockDelimiters) change braces todo/endin ways that alter readability. - Large projects with many enabled cops slow down inspections. If typing feels laggy, disable expensive cops in
rubocop.yml(e.g.,Metrics/AbcSize) or increase Settings > Editor > Inspections > Ruby > RuboCop > Inspection severity to run only on explicit code analysis (Ctrl+Alt+Shift+I). - RubyMine does not install RuboCop. Ensure
rubocopis in yourGemfileandbundle installhas run. The IDE will show a warning in the Inspections dialog if it cannot locate the executable. - Behavior varies by RubyMine version. Check the release notes for your version (Help > About) if auto-correct stops working after an upgrade.
Verify your setup today
- Open Settings > Editor > Inspections > Ruby > RuboCop. Confirm the checkbox is ticked and the
rubocop.ymlpath is detected. - Open a Ruby file with a known violation (add a trailing comma to a hash if needed). Verify the editor highlights it and Alt+Enter offers a RuboCop quick-fix.
- Run the quick-fix and confirm the offense resolves according to your
rubocop.yml.
Once verified, add rubocop -A to your pre-commit hook (via overcommit or lefthook) as a safety net for teammates not using RubyMine. The IDE catches issues early; the hook catches the rest.