Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Latest commit

 

History

History
106 lines (77 loc) · 2.65 KB

linting.md

File metadata and controls

106 lines (77 loc) · 2.65 KB

Linting

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

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

RuboCop is a Ruby static code analyzer and formatter, based on the community Ruby style guide

Configuration Options

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

Standard is the Ruby Style Guide with linter and automatic code fixer

Configuration Options

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

Reek is a code smell detector for Ruby

Configuration Options

"ruby.lint": {
  "reek": true
}

or

"ruby.lint": {
  "reek": {
    "command": "reek",  // setting this will override automatic detection
    "useBundler": true
  }
}