Copy the following to .rubocop.yml
inherit_from:
# For a rails project
- https://raw.githubusercontent.com/web-ascender/ruby-style-guide/master/rails.yml
# For a non-rails project
# - https://raw.githubusercontent.com/web-ascender/ruby-style-guide/master/ruby.yml- Add
.rubocop-*to your.gitignorefile - For legacy projects, run
rubocop --auto-gen-configand add.rubocop_todo.ymlto theinherit_fromlist in.rubocop.yml - Set up overcommit with a pre-commit-hook for rubocop
- For projects using rspec, set up rubocop-rspec
For VS Code, it is strongly recommended to use the ruby extension.
At a miniumum, I recommend adding the following to your global settings to enable the rubocop linter:
"ruby.lint": {
"rubocop": true,
"ruby": true
}
The ruby extension can also be configured to have rubocop auto-format files whenever you save them. I recommend enabling this on a project by project basis by adding the following to your workspace settings:
"ruby.format": "rubocop",
"[ruby]": {
"editor.formatOnSaveTimeout": 2000,
"editor.formatOnSave": true
}
Ruby intellisense can be enabled by installing the npm ruby-method-locate package. You will need to run npm i -g ruby-method-locate from the command line and then add the following to your global settings:
"ruby.intellisense": "rubyLocate"
Ruby autocompletion can be enabled with the rcodetools gem. You will need to run gem install rcodetools from within the correct version of ruby and add the following to your global settings:
"ruby.codeCompletion": "rcodetools"