misogi / vscode-ruby-rubocop

Rubocop extension for Visual Studio Code
https://marketplace.visualstudio.com/items/misogi.ruby-rubocop
MIT License
137 stars 68 forks source link

[FEATURE] Support for docker #112

Open jkasten2 opened 4 years ago

jkasten2 commented 4 years ago

Feature Request

Would be great if ruby and rubocop didn't have to be installed on the host machine and instead could be run in docker if workspace is using it.

Environment Details

I am running Windows 10 with ruby in a docker container in WSL2 with Ubuntu. Once this issue is solved to run rubocop in a docker container WSL2 shouldn't be a factor but stated for more context just in case.

What I have Tried

Tried setting the "Execute Path" in the setting to docker-compose exec CONTAINER_NAME_HERE bundle exec however I just get an "... is not executable" warning.

Alternative

I was able to use the Docker Linter VScode extension instead which runs rubocop and fills in the lint errors in to VSCode as expected.

almokhtarbr commented 4 years ago

any update guys ?

artem-russkikh commented 4 years ago

Here is my workaround

I've created file in project folder and make it executable:

touch ./rubocop
chmod +x ./rubocop

Filled rubocop file with:

#!/bin/sh
docker-compose exec -T SERVICE_NAME_HERE bundle exec rubocop -c .rubocop.yml "$@"
# or you can start container on each lint:
# docker-compose run --no-deps --entrypoint= --rm SERVICE_NAME_HERE bundle exec rubocop -c .rubocop.yml "$@"

Setup vscode-ruby-rubocop plugin setting:

{
  "ruby.rubocop.executePath": "./"
}

I thing this way is not good to run linter through docker, this should be possible to do using plugin configuration.

gabrielgaraujo commented 3 years ago

Another option is VS Code Remote - Containers But @artem-russkikh's suggestion still simpler and functional.