The language server currently supports linting via the following linters:
Additional linter support can be provided but they must conform to the following rules:
- Input must be provided via
stdin
- Output must be provided via a machine parsable format (ideally json)
Linter support for linters that run over a whole project (eg brakeman
) is being investigated (see #512)
Configuration for linting is provided under the ruby.lint
key.
The global useBundler
flag does not apply to linters. This is an outstanding issue and will be corrected later. Each linter allows the option of overriding useBundler
.
RuboCop is a Ruby static code analyzer and formatter, based on the community Ruby style guide
See the RuboCop CLI args for more details on the support configuration options
"ruby.lint": {
"rubocop": true
}
or
"ruby.lint": {
"rubocop": {
"command": "rubocop", // setting this will override automatic detection
"useBundler": true,
"lint": true, // enable lint cops
"only": ["array", "of", "cops", "to", "run"],
"except": ["array", "of", "cops", "not", "to", "run"],
"require": ["array", "of", "ruby", "files", "to", "require"],
"rails": true, // requires rubocop-rails gem for RuboCop >= 0.72.0
"forceExclusion": true // for ignoring the excluded files from rubocop.yml
}
}
Standard is the Ruby Style Guide with linter and automatic code fixer
See the standard docs for more details on these configuration options
"ruby.lint": {
"standard": true
}
or
"ruby.lint": {
"standard": {
"command": "standard", // setting this will override automatic detection
"useBundler": true,
"only": ["array", "of", "cops", "to", "run"],
"except": ["array", "of", "cops", "not", "to", "run"],
"require": ["array", "of", "ruby", "files", "to, "require"]
}
}
Reek is a code smell detector for Ruby
"ruby.lint": {
"reek": true
}
or
"ruby.lint": {
"reek": {
"command": "reek", // setting this will override automatic detection
"useBundler": true
}
}