Let’s start using RuboCop! The release of MeowCop, the best configs for introducing RuboCop!

  • Post author:
  • Post last modified:2020-11-25
  • Post category:Code Review
  • Reading time:3 mins read

Hello! This is pocke, the RuboCop lover!
I’m happy to inform you of the release of MeowCop, a Gem for configuring RuboCop.

Default settings for RuboCop are hard to use…

You may ask, what lead to the release of this Gem?
Well, there was a problem that RuboCop’s default settings were a bit awkward to use.

RuboCop provides a lot of rules, and many of them are enabled by default.
This means that RuboCop verifies various rules for you without any configurations.

However, from a different perspective, this also means that RuboCop will emit many, many warnings if you don’t configure it yourself. A situation like this is a big obstacle in introducing RuboCop.

Why will there be so many warnings?

So, why will there be so many warnings?
The answer is because RuboCop checks the coding style of Ruby codes.

There are many coding styles, differing between people, companies, projects, and so on.
So, when you use the default settings fo/Users/KF/Downloads/ブログ記事翻訳依頼_translated/blog_article_2_engr RuboCop, a tool for general use, a ton of warnings occur, because the configurations are not optimized for each project.

A solution: not indicating coding style problems at all

MeowCop can solve this problem.

MeowCop disables rules that are different for each project, such as ones concerning coding style.
Rules not about style are left enabled, like codes that can lead to bugs or problems concerning performance.
Like this, MeowCop allows you to effectively introduce RuboCop without having to worry about those heaps of warnings.

If it becomes necessary to enable those rules concerning style after introducing MeowCop, you can overwrite the settings in .rubocop.yml

How to install

Install the gem using the following command:

$ gem install rubocop meowcop

or, add the following code to your Gemfile

gem 'rubocop', require: false
gem 'meowcop', require: false

Also, you need to add the code below to your .rubocop.yml.
If you don’t have a .rubocop.yml, please create one.

inherit_gem:
meowcop:
- config/rubocop.yml

By executing the rubocop command with these settings, Rubocop will run with the settings by MeowCop applied.

Summary

By using MeowCop, you can introduce RuboCop, starting with only the rules that can be used in any project.
If you want to introduce RuboCop, but feel like making those config files following the style guides is a hard task, do give it a try!

Also, MeowCop can be used on SideCI, immediately.
It should be noted that when you execute RuboCop on SideCI, the settings by MeowCop are used for repositories that don’t have a .rubocop.yml file.

More articles about RuboCop


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

Leave a Reply

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