Extract Hidden Coding Styles to .rubocop.yml with Gry

We’re happy to announce the release of Gry, an automatic .rubocop.yml generation tool.

https://github.com/pocke/gry

What is Gry?

Gry is a tool which automatically generates a config file for RuboCop (.rubocop.yml). By using Gry, you can analyze your project’s source codes to automatically generate a .rubocop.yml best optimized for your project.

Like this, Gry can help you drastically reduce the time you originally spent writing .rubocop.yml manually and use RuboCop in a way that suits your project better.

Installation

Gry is provided as a Gem, so you can install it with the following gem command:

Please note that Gry is dependent on the newest version of RuboCop at the time this article was written (v0.47.1)
There may be a chance that the .rubocoop.yml file will not be generated properly when using an older version of RuboCop. In that case, please update RuboCop, and try again.

How to Use

Using Gry is very simple. Only the following two steps are needed:

  1. Go to the directory you want to generate .rubocop.yml
  2. Run gry

When run, gry will write the generated .rubocop.yml to the standard output.

To actually use this output for your configuration, paste it manually to .rubocop.yml, or run gry >> .rubocop.yml.

Keep in mind that running Gry may take some time. The more code in the project, the longer it will take.

Summary

As shown, using Gry can help you greatly reduce the time spent on configuring .rubocop.yml. When we ran Gry on several projects, about 20 Cop configurations could be automatically generated.

Also, since they have the same concept, you can use MeowCop, which we released before, with Gry.
Please consider giving it a try too!
Release Article: [Let’s start using Rubocop! The release of MeowCop, the best configs for introducing Rubocop! – SideCI Blog](eng blog url)

Leave a Reply

Your email address will not be published. Required fields are marked *