LoginSignup
4
2

More than 1 year has passed since last update.

ruby-rubocop is not working in vscode

Last updated at Posted at 2019-03-18

解決策

settings.json
{
    "editor.formatOnSaveTimeout": 5000,
}

実際の流れとか

environment

macbook pro 2018 13inch
visual studio code

Per this comment on the vscode-ruby-rubocop GitHub, you can use the following settings:

{
    "editor.formatOnSave": true,
    "editor.formatOnSaveTimeout": 5000,
    "ruby.rubocop.executePath": "path/where/rubocop/is/located",
    "ruby.format": "rubocop",
}

Just applied them to my user settings on my local box and it appears to work. VS Code was throwing an error for my ruby.rubocop.executePath setting saying it wasn't executable, and removing the line appears to not cause that error to show, and still formats my code accordingly. Setting a lower timeout (I tried 2500) also seems to break auto format on saving, so I'd suggest leaving it at 5000.
ローカルボックスの自分のユーザー設定にそれらを適用するだけで、うまくいくようです。私のruby.rubocop.executePathの設定にVS Codeが実行可能ではないというエラーを投げていたため、行を削除してもそのエラーが表示されないように見えますが、それでもコードは適切にフォーマットされます。より短いタイムアウトを設定すると(私は2500を試した)保存時に自動フォーマットを壊すように思われるので、私はそれを5000のままにすることをお勧めします。

following is working for me:

{
    "editor.formatOnSave": true,
    "editor.formatOnSaveTimeout": 5000,
    "ruby.rubocop.executePath": "path/where/rubocop/is/located",
    "ruby.format": "rubocop",
}

色々やったのにうまくいかなかった。
エディターの設定を直せばうまくいくとは想像できなかった。(ずっとrubocopの設定を検索していた)
まあ、これで自動フォーマットされるし、サボれる( ・∇・)!!

https://qiita.com/sensuikan1973/items/219a843e4654e6c2e10d
https://qiita.com/astronaughts/items/760d56fb5674707a9a0f
https://qiita.com/ovrmrw/items/86310cb9ad5707ea27ee
https://marketplace.visualstudio.com/items?itemName=misogi.ruby-rubocop

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2