RubyMine 2017.2 Release Candidate: Quick-fixes for RuboCop

Artem Sarkisov

RubyMine 2017.2 RC (build 172.3317.60) is out. This release candidate features quick-fixes for RuboCop, and brings other minor improvements.

Since the previous major release (v2017.1) RubyMine has displayed RuboCop offenses treating and highlighting them as code inspections, but lacked an ability to autocorrect found code smells. Now we have improved that partial solution by adding proper quick-fixes:

rubocop-quick-fixes

If you press Alt+Enter, RubyMine will suggest a quick-fix for a found error, and auto-correct all errors in the file with RuboCop. So no more jumping to the terminal to fix your code with RuboCop!

By the way, RuboCop inspections and quick-fixes are now also available in scratch files.

Here are some other improvements in this build:

Download this EAP from our website.

See the release notes for the full list of improvements, and submit any issues to our bug tracker.

Join other RubyMine users and the dev team on Slack.

Cheers!

Your RubyMine Team

Comments below can no longer be edited.

15 Responses to RubyMine 2017.2 Release Candidate: Quick-fixes for RuboCop

  1. Bruno Facca says:

    July 18, 2017

    Very useful feature. Thank you!

  2. Denis says:

    July 19, 2017

    What are the hotkeys for this?

    • Artem Sarkisov says:

      July 19, 2017

      Alt+Enter; sorry, I was sure I added that to the post.

      • Timothy D Heilman says:

        February 20, 2019

        Is there a hotkey that *doesn’t* require

        A) the asynchronous offense scanning to have completed since the file was opened, in order to identify the offense locations that are then required at B), nor
        B) the insertion point to be *at* a RuboCop offense

        in order to function?

        I’m thinking of the equivalent of command-option-L that applies formatting rules according to RubyMine’s “Ruby” code style which, unfortunately, cannot be made fully consistent with RuboCop’s indentation rules. Thereafter I want a hotkey to apply RuboCop’s indentation rules which unfortunately don’t quite cover *all* the (non-indentation) whitespace niceness that RubyMine’s code style *does*.

        So I would like to have a muscle macro:

        command-option-L,

        that, regardless of the scanning nor cursor position, first applies the RubyMine Ruby code style rules (command-option-L), then corrects all offenses (). Can such a hotkey exist without the A) and B) requirements, above?

        • Timothy D Heilman says:

          February 20, 2019

          failed HTML escaping above left out some text: ”

          command-option-L, *hotkey*

          that, regardless of the scanning nor cursor position, first applies the RubyMine Ruby code style rules (command-option-L), then corrects all offenses (*hotkey*).

        • Olga Kuvardina says:

          February 25, 2019

          We have a similar feature request on our tracker (going to discuss it during the next planning) so it’d be great if you could leave a comment there specifying what you’d expect from it: https://youtrack.jetbrains.com/issue/RUBY-19589

  3. Rob Vitaro says:

    July 19, 2017

    Is there a way to configure the Rubocop that runs within RubyMine? I would like to ignore something, but don’t know where to set that.

    • Artem Sarkisov says:

      July 20, 2017

      Hi Rob;
      Currently we don’t have such an opportunity, so in v2017.2 you can only fix all possible RuboCop offenses. But there’s an open discussion on Slack about how to improve that http://slack.rubymine.org/

      You can either jump to the discussion and add your comments there, or write the list of offenses that you want/don’t want to auto-correct right here, and I’ll add it to the list.

      • Artem Sarkisov says:

        July 20, 2017

        Below is the quote from my call for discussion about custom RuboCop quick-fixes on Slack:

        `As you know, the new v2017.2 provides in-editor RuboCop quick-fixes. If you see an offense in the editor (gray-highlighted code) and hit _Alt+Enter_, RubyMine will suggest an auto-correction and fix *all offenses in a file*.
        We’d like to provide a way to *auto-correct offenses one by one*. As RuboCop can’t do that, we’ll have to implement this as a new feature in RubyMine. To do that, we need your help to choose the most important offenses that you auto-correct with RuboCop.
        *Let’s start a discussion here, and make a list of such RuboCop offenses*.`

      • Rob Vitaro says:

        July 20, 2017

        Appreciate the reply, thank you. Honestly, my biggest complaint is the huge number of “this line has too many characters” I see every day. It’s just distracting. Long code lines are not a problem at my company.

  4. Bruno Facca says:

    July 20, 2017

    Instead of correcting offenses one by one, maybe Rubymine could allow us to configure which Robocop offenses should be displayed (and corrected). Something similar to the “code style” and “inspection” settings which are currently available. IMO that would be a better approach as different companies have different coding style guidelines so we would be able to customize Rubymine to always behave according to the guidelines we’re currently following. One example is choosing whether we’d like to use single quotes or double quotes with strings that do not contain interpolation.

    • Rob Vitaro says:

      July 20, 2017

      I think this would be the perfect solution

    • Bruno Facca says:

      July 20, 2017

      For now, we can customize Rubocop’s rules by editing “default.yml”, “disabled.yml” and “enabled.yml”. To find the path to these files, type the following in the command prompt: gem contents rubocop | grep “.yml”. This should work in any O.S. with Ruby installed (*nix OSs already have grep and the Ruby Windows Installer installs MinGW, which includes grep). Rails developers might want to change “Rails: Enabled: false” to true in “disabled.yml”.

  5. Steven Holloway says:

    October 23, 2017

    It would be ideal if the Rubymine would honour the .rubocop file in project
    This seems like a no brainer.

    • Artem Sarkisov says:

      October 23, 2017

      Hi, Steven. RubyMine should already respect `.rubocop` configs. Does RM ignore that in your case?

Subscribe

Subscribe for updates