Help us understand the problem. What is going on with this article?

ruby-rubocop is not working in vscode

solution

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

environment

macbook pro 2018 13inch
visual studio code

https://stackoverflow.com/questions/48030698/vscode-vscode-ruby-rubocop-how-to-auto-correct-on-save

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のままにすることをお勧めします。

https://github.com/misogi/vscode-ruby-rubocop/issues/49#issuecomment-417617844

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away