Extract Hidden Coding Styles to .rubocop.yml with Gry

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


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.


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

$ gem install gry

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.

$ cd your/project/path
$ gry
TargetRubyVersion: 2.3
Enabled: true
# EnforcedStyle: outdent => 15 offenses
# EnforcedStyle: indent => 0 offense
EnforcedStyle: indent
Enabled: true
# EnforcedStyle: with_first_parameter => 12 offenses
# EnforcedStyle: with_fixed_indentation => 2 offenses
EnforcedStyle: with_fixed_indentation
Enabled: true
# EnforcedStyle: is_a? => 0 offense
# EnforcedStyle: kind_of? => 10 offenses
EnforcedStyle: is_a?
Enabled: true
# .....

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.


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)

More articles about RuboCop

For more information about Sider, please go to our website.

Aki Asahara

CEO of Sider. Aki joined Fixstars in 2008 and served major clients such as the US Airforce, MIT, USC, Toyota, and Hitachi High-technologies. After his successful tenure, he was appointed CEO of US operations in 2012. He was appointed CEO of Sider in 2019. He holds a Ph.D. in Astrophysics from Kyoto University and is a Certified Scrum Master.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.