RubyMine 2017.1 EAP 2: Create gemsets quickly & work with RuboCop

Posted on by Artem Sarkisov

Hi everyone,

RubyMine 2017.1 EAP 2 (171.2272.16) is out and available for download. Besides a number of bug fixes, this Early Access Program provides a way to create RVM gemsets for Rails applications right from the New Project wizard, and features RuboCop support.

Creating Gemsets From the New Project Wizard

If you haven’t used gemsets before, you might want to know that a gemset is a container used to keep separate gems for each project. Gemsets allow you to change gems and their versions in one project without being afraid of affecting your other projects. Jump to the RVM documentation to learn how gemsets can improve your coding experience.

To create a gemset for your new Rails project in RubyMine, follow these steps:

Open RubyMine and click Create New Project from the Welcome screen (File | New Project). Choose a new Rails application.

creatiing_gemset_rubymine

As you can see in the GIF above, when you specify a name for your project, RubyMine automatically suggests a similarly named gemset. Click Create to have the IDE install a gemset for your new project. Leave the box checked so that the gems are put in this gemset when generating your Rails project.

Since you don’t have Rails set up in your newly created gemset, you can install any available version in the Rails Version field (this might take up to several minutes):

create_rails_cut

After installing Rails, click Create in the lower right corner of the New Project wizard. The IDE will generate your Rails application with all the gems mounted in the preconfigured gemset. The IDE will also create .ruby-gemset and .ruby-version files, specifying the gemset and the Ruby version used in the project.

Go to Preferences | Languages & Frameworks | Ruby SDK and Gems to see your SDK configurations and available gems:

Gemset_Preferences

Note that you may face issues when creating a gemset for a New Rails API. This problem will be fixed in the next stable release (v2017.1).

RuboCop Support

Now the IDE interacts with RuboCop, analyzing code in the background and displaying errors according to the RuboCop’s severity table:

SEVERITY_MAP.put("refactor", HighlightSeverity.WEAK_WARNING);
SEVERITY_MAP.put("convention", HighlightSeverity.WEAK_WARNING);
SEVERITY_MAP.put("warning", HighlightSeverity.WARNING);
SEVERITY_MAP.put("error", HighlightSeverity.ERROR);
SEVERITY_MAP.put("fatal", HighlightSeverity.ERROR);

RuboCop inspections are treated the same way as other code inspections:

rubocop

If the project SDK has the rubocop gem installed, the RuboCop inspection will be enabled by default. Otherwise, RubyMine will suggest to install the missing gem and enable the inspection:

rubocop_suggest

Other improvements

Here are some other improvements for this EAP:

  • The inspection of frozen strings modification has been fixed and now doesn’t show false warnings.
  • Underscores in the middle of the words now respect CamelHumps settings correctly in markdown files.
  • The ability to change language level for JRuby and Rubinius, which had previously been removed, has been reinstated.

Follow this link for the full list of changes.

Download the newest RubyMine EAP and share your feedback with us! Leave your comments below, and submit your feature requests and bug reports to our tracker.

Cheers!

Your RubyMine Team

Comments below can no longer be edited.

17 Responses to RubyMine 2017.1 EAP 2: Create gemsets quickly & work with RuboCop

  1. RubyMine 2017.1 EAP 3: Updated New Ruby Class Dialog, Fixed Markdown | RubyMine Blog says:

    January 20, 2017

    […] ← RubyMine 2017.1 EAP 2: Create gemsets quickly & work with RuboCop […]

  2. Raido says:

    February 13, 2017

    Is the “Reformat Code” action also following RuboCop style guidelines?

    • Artem Sarkisov says:

      February 15, 2017

      Hey Raido,

      Not really. The Reformat Code action is following Code Style settings (Preferences | Editor | Code Style | Ruby).

      But the appropriate RuboCop inspections will sure work in place.

      • Raido Paaslepp says:

        February 16, 2017

        Are you going to support Reformat Code according to Rubocop as well? Because it’s pretty stupid that inspections show one thing and the Reformat Code does another thing.

      • Raido Paaslepp says:

        February 16, 2017

        The biggest problem with the Reformat Code is that it’s inflexible and forces styles, which are not very widespread.

        The biggest headache is that “Align multiline list items” indents the arguments relative to method, if arguments start from the next line.

        E.g. it’s impossible to configure Ruby Code Style to match the following style http://pasteboard.co/yWlD5BFuQ.png

  3. Marat Amerov says:

    March 1, 2017

    Is there support .rubocop.yml config?

    • Artem Sarkisov says:

      March 2, 2017

      Hey Marat,

      Could you please be more specific? You are also welcome to add your request/suggestions to this task https://youtrack.jetbrains.com/issue/RUBY-15896

      • Chris Taylor says:

        September 14, 2017

        It’s possible to configure Rubocop various Cops via .rubocop.yml files. This would be a great feature to have. For example, I could configure my max line length to be something other than the default 80 characters.

        • Artem Sarkisov says:

          October 2, 2017

          You can configure your .rubocop.yml file, and RubyMine will surely respect that settings. Or did you mean something else?

          • Georgia Andrews says:

            March 22, 2018

            I just upgraded RubyMine to 2017.3 form a 2016 version and it’s not respecting the .rubocop.yml file I already had in my project. For example, I changed my preferred quotes in my .rubocop.yml file to prefer single quotes instead of double quotes (to match RubyMine’s style), and the Rubocop inspection is not respecting that change.

            • Artem Sarkisov says:

              March 23, 2018

              Hi Georgia! Before we open a ticket, could you please try saving your .rubocop.yml file manually (Ctrl/Cmd + S) to see if RubyMine catches the new rules?

              • Georgia Andrews says:

                March 23, 2018

                That did appear to do it, thanks! I’m so used to RubyMine autosaving that requiring a manual save is either its own bug or should be mentioned on the docs page about how to use Rubocop with RubyMine.

              • Artem Sarkisov says:

                March 23, 2018

                Yeah normally the autosave should do the trick, so we’ll try to investigate why it doesn’t work in this specific case, and put a note in the doc. Thank you for the report!

  4. RubyMine 2017.1 Released: Docker, RuboCop, Puppet, Test Generation for Rails, and More! | RubyMine Blog says:

    March 24, 2017

    […] We’ve added the ability to create new RVM gemsets from the New Project wizard, which we think is rather convenient. See the related blog post. […]

  5. RubyMine 2017.1リリース: Docker, RuboCop, Puppet, RoRのテスト生成など! | JetBrains ブログ says:

    April 11, 2017

    […] 新しいプロジェクトウィザードから新しいRVM gemsetsを作成する機能を追加いたしました。これはかなり便利だと思います。関連記事をご参照ください。 […]

  6. RubyMine 2017.2 Release Candidate: Quick-fixes for RuboCop | RubyMine Blog says:

    July 13, 2017

    […] 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 […]

Subscribe

Subscribe for updates