#work/reference
Ruby linting vs code
Setting up vim bindings on VS code
Ruby plugin
- Install
solargraph
gem so that you can get code completion - Install
rubocop
andrubocop-airbnb
gems so you can get linting (reading this last part suggests to me that this may be all we need)
Go through the ruby plugin and in each of the different sections there will be configurations for you to choose and
We use rubocop
for linting so set it up with that.
These are modified from the instructions in the README to fit our particular use case at Canvas.
In User settings
// Basic settings: turn linter(s) on
“ruby.lint”: {
“reek”: false,
“rubocop”: true,
“ruby”: false,
“fasterer”: false,
“debride”: false,
“ruby-lint”: false
},
// Time (ms) to wait after keypress before running enabled linters. Ensures
// linters are only run when typing has finished and not for every keypress
“ruby.lintDebounceTime”: 500,
To automatically format ruby files when you save. If you’ve already installed rubocop gem all you should need to do is add the following to your settings.json:
"[ruby]": {
"editor.formatOnSave": true
},
"ruby.format": "rubocop",
"editor.formatOnSaveTimeout": 2500
Apparently this doesn’t work perfectly out of the box if you’re using rvm
. For rubocop
installed with rvm
you may need to explicitly tell VS code where to find the executable. So your config will look something like this:
{
"ruby.lint": {
"reek": false,
"rubocop": {
"path": "path/to/folder/containing/rubocop"
},
"ruby": false, //Runs ruby -wc
"fasterer": false,
"debride": false,
"ruby-lint": false
},
// Formatting to apply cops on save
"[ruby]": {
"editor.formatOnSave": true
},
"ruby.format": "rubocop",
"editor.formatOnSaveTimeout": 2500,
"ruby.lintDebounceTime": 500,
"ruby.rubocop.executePath" : "/Users/clairecanvas/.rvm/gems/ruby-2.5.0/bin/"
}