Use a Ruby Linter
Published: Nov 17th, 2020
This is part of Joyful Rails, a list of recommendations to make developing your Rails app more productive and joyful.
In this article, we are talking about using a Ruby linter.
The longer you wait to add a Ruby linter, the more work you will have to correct style errors that have accumulated. For that reason, I recommend adding a linter, such as RuboCop, as early as possible.
Having a consistent style makes code easier to read and maintain. Using a linter makes it easy to conform to a consistent style. In a lot of cases, your linter can make corrections automatically.
- Add the RuboCop gem. Add the
gem 'rubocop'to the development group of your
- Configure RuboCop. Add a
.rubocop.ymlwith the RuboCop configuration.
- Run RuboCop with auto-correct,
- Correct errors that RuboCop cannot correct automatically.