It is a library that checks whether the written code complies with the coding standards. Rubocop is famous as a parsing tool, but since there are various settings, this time we will introduce rubocop-airbnb customized for the development site.
Gemfile
group :development, :test do
gem 'rubocop-airbnb'
end
$ bundle install
Create new .rubocop.yml and .rubocop_airbnb.yml in the same directory as the Gemfile.
ruby:.rubocop.yml
inherit_from:
- .rubocop_airbnb.yml
AllCops:
Exclude:
- 'bin/*'
- 'config/**/*'
- 'db/**/*'
- 'spec/spec_helper.rb'
ruby:.rubocop_airbnb.yml
require:
- rubocop-airbnb
If you get an error when calling, please be careful because you may have forgotten to add "." Or "_" in this file or you may have made a typo.
$ rubocop --require rubocop-airbnb
$ rubocop --require rubocop-airbnb -a
It will be harder to fix later, so please try to introduce it before you start writing code.
https://github.com/airbnb/ruby/tree/master/rubocop-airbnb
Recommended Posts