[Rails] Introduction of Rubocop

[Rails] Introduction of Rubocop

When I joined a Ruby test automation project a year ago at SHIFT ASIA, I had used RuboCop tool for the first time. RuboCop is a Ruby source code analysis tool that automatically checks if your code conforms to the Ruby style guide from the Ruby community and all mistakes like Indentation deviations, unnecessary spaces, line breaks, ... are automatically corrected by typing a specific command, therefore you can format the code so that it is easy to read for you as well as others.

So, if you're starting a ruby test automation project, using RuboCop is definitely recommended. Now I will introduce to you on how to use RuboCop:

1/ Installing RuboCop

If you already have ruby and can use RubyGems, installation is extremely simple:

$ gem install rubocop

2/ How to use RuboCop

To use RuboCop, simply move to the Ruby project you would like to check and execute the rubocop command.

cd path/to/your/project
bundle exec rubocop

When you do this, the check will be carried out on the .rb file or Gemfile, and the results will be printed to the console.


RuboCop is a very powerful and the most popular code linting tool for the Ruby language. Using RuboCop when developing Ruby on Rails applications helps developers to avoid common mistakes, prevents the code formatting discrepancies and allows them to create a codebase that is well maintained and easy to understand. That's all I  I'd like to introduce to you about this tool and hope it's helpful. And finally, thank you for your reading.