vscode-ruby version: 0.28.1, and also commit 7b5b602useLanguageServer is true in your configuration?) yesRuboCop is run with these arguments:
~javascript
[
"bundle",
"exec",
"rubocop",
"-s",
"/path-to-file.rb",
"-f",
"json"
]
~
Reek is run with these arguments:
~javascript
[
"bundle",
"exec",
"reek",
"-f",
"json",
"--stdin-filename",
"/path-to-file.rb"
]
~
RuboCop is run with these arguments:
~javascript
[
"bundle",
"exec",
"rubocop",
"-s",
"'/path-to-file.rb'", // <--- note the extraneous single quotes!
"-f",
"json"
]
~
Reek is run with these arguments:
~javascript
[
"bundle",
"exec",
"reek",
"-f",
"json",
"--stdin-filename",
"'/path-to-file.rb'" // <--- note the extraneous single quotes!
]
~
To reproduce:
Create a shell script ~/fake-rubocop that prints the exact arguments passed:
~~~bash
set -x
exec bundle exec rubocop "$@"
~~~
Make sure to chmod +x it.
Create a shell script ~/fake-reek that prints the exact arguments passed:
~~~bash
set -x
exec bundle exec reek "$@"
~~~
Make sure to chmod +x it.
~json
"ruby.useLanguageServer": true,
"ruby.lint": {
"rubocop": {
"command": "/path-to-home-directory/fake-rubocop"
},
"reek": {
"command": "/path-to-home-directory/fake-reek"
}
},
~
Open a Ruby project directory. Inside that project directory, open a random Ruby file.
In the Ruby Language Server output, observe that fake-rubocop logs this:
~~~
exec bundle exec rubocop -s ''\''/path-to-file.rb'\''' -f json
~~~
We expect no extraneous quotes:
~~~
In the Ruby Language Server output, observe that fake-reek logs this:
~~~
exec bundle exec reek -f json --stdin-filename ''\''/path-to-file.rb'\'''
~~~
We expect no extraneous quotes:
~~~
In packages/language-server-ruby/src/linters/RuboCop.ts:
~typescript
let args = ['-s', '${documentPath.fsPath}', '-f', 'json'];
~
In packages/language-server-ruby/src/linters/Reek.ts:
~typescript
return ['-f', 'json', '--stdin-filename', '${documentPath.fsPath}'];
~
I suspect that the author meant to prevent any issues with spaces in filenames. However, Linters are executed through cross-spawn, which doesn't execute commands through a shell. There should be no problems with spaces in filenames: each element in the argument array represents exactly one argument, with no shell trying to split up filenames by space.
This change was introduced in #647 by @coneybeare.
@coneybeare would you be able to provide your insight here?
ok. @coneybeare if you don't have any comments here it sounds like #647 caused a regression that I'd like to correct. Absent input to the contrary I'll likely merge #720
Giving this through the end of this week then I'll be merging.
oh hm, I actually did comment, not sure where it went.
Here was the original issue that prompted my PR. Despite OPs assertion that There should be no problems with spaces in filenames, I saw that they were necessary, at least at the time of the PR.
As long as the proposed fix doesn't introduce a regression for what I fixed, I am onboard.
Any updates?
I plan on looking into the issue #641 that @coneybeare referenced. I just haven't had time so far.
@coneybeare I've tested #641. Just like you, I'm on macOS. I've confirmed that my PR #720 has no problems with spaces in filenames.
Rubocop 1.12.0, Ruby 2.7.2, macOS Catalina.
Create a project directory ~/ruby project with spaces
Create a file ~/ruby project with spaces/sub dir/rubyfile_bad.rb with:
~ruby
def bad
"rubocop will complain about double quotes"
end
~
Create a file ~/ruby project with spaces/sub dir/rubyfile_good.rb with:
~ruby
def good
"rubocop will not complain about double quotes"
end
~
Create a file ~/ruby project with spaces/.rubocop.yml with:
~~~yaml
Style/FrozenStringLiteralComment:
Enabled: false
Style/StringLiterals:
Exclude:
Create a file ~/ruby project with spaces/.vscode/settings.json with:
~json
{
"ruby.useLanguageServer": true,
"ruby.lint": {
"rubocop": true
}
}
~
Matches expected behavior.
This issue has not had activity for 30 days. It will be automatically closed in 7 days.
Please don't auto-close this PR. It's awaiting review.