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 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:
- Go to the directory you want to generate
gry will write the generated
.rubocop.yml to the standard output.
$ cd your/project/path
# EnforcedStyle: outdent => 15 offenses
# EnforcedStyle: indent => 0 offense
# EnforcedStyle: with_first_parameter => 12 offenses
# EnforcedStyle: with_fixed_indentation => 2 offenses
# EnforcedStyle: is_a? => 0 offense
# EnforcedStyle: kind_of? => 10 offenses
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
- Trying the Rails or Lint options in RuboCop
- Using RuboCop for quick automated code reviews with Docker
- Use RuboCop to check the conformity of your Ruby code with the style guide
- Analyzing code with RuboCop on a Ruby on Rails project
- Let’s start using RuboCop! The release of MeowCop, the best configs for introducing RuboCop!
- Educate RuboCop, try out rubocop.yml which prioritize the speed to the rules
For more information about Sider, please go to our website.