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

Rubocop requires relative paths #641

Closed
coneybeare opened this issue Aug 1, 2020 · 3 comments · Fixed by #647
Closed

Rubocop requires relative paths #641

coneybeare opened this issue Aug 1, 2020 · 3 comments · Fixed by #647
Labels

Comments

@coneybeare
Copy link
Contributor

coneybeare commented Aug 1, 2020

When running a rubocop linter, absolute paths are being passed to the command, causing the underlying command to fail and never return in the Ruby Language Server output panel.

Your environment

  • vscode-ruby version: 0.27.0
  • Ruby version: 2.7.1p83
  • Ruby version manager (if any): rvm
  • VS Code version: 1.47.3
  • Operating System: MacOS 10.15.5
  • Using language server? (eg useLanguageServer is true in your configuration?) true
  • Rubocop version: 0.88.0

Expected behavior

I would expect the linter to lint the file.

Actual behavior

The file does not lint, due to absolute paths being passed.

Running the command listed in the output panel

$ cat app/overrides/change_footer.rb | rubocop -s /Users/[REDACTED]/Library/Mobile Documents/com~apple~CloudDocs/path/to/project/app/overrides/change_footer.rb -f json -l
-s/--stdin requires exactly one path, relative to the root of the project. RuboCop will use this path to determine which cops are enabled (via eg. Include/Exclude), and so that certain cops like Naming/FileName can be checked.

The passed path should be relative:

$ cat app/overrides/change_footer.rb | rubocop -s app/overrides/change_footer.rb -f json -l
{"metadata":{"rubocop_version":"0.88.0","ruby_engine":"ruby","ruby_version":"2.7.1","ruby_patchlevel":"83","ruby_platform":"x86_64-darwin19"},"files":[{"path":"app/overrides/change_footer.rb","offenses":[]}],"summary":{"offense_count":0,"target_file_count":1,"inspected_file_count":1}}%

Relevant settings.json entries

"ruby.codeCompletion": "rcodetools",
  "ruby.format": false,
  "ruby.intellisense": "rubyLocate",
  "ruby.lint": {
    "rubocop": {
      "command": "rubocop",
      "lint": true
    }
  },
  "ruby.useLanguageServer": true,

Ruby Language Server output

[Info  - 7:51:18 AM] Initializing Ruby language server...
Loading Ruby tree-sitter syntax from /Users/[REDACTED]/path/to/vscode/extensions/rebornix.ruby-0.27.0/dist/server/tree-sitter-ruby.wasm
Lint: executing rubocop -s /Users/[REDACTED]/Library/Mobile Documents/com~apple~CloudDocs/path/to/project/app/overrides/change_copyright.rb -f json -l...
Lint: executing rubocop -s /Users/[REDACTED]/Library/Mobile Documents/com~apple~CloudDocs/path/to/project/app/overrides/change_products_sidebar.rb -f json -l...
Lint: executing rubocop -s /Users/[REDACTED]/Library/Mobile Documents/com~apple~CloudDocs/path/to/project/app/overrides/change_footer.rb -f json -l...

Relevant Rubocop Info:

From official docs

Pipe source from STDIN. This is useful for editor integration. Takes one argument, a path, relative to the root of the project. RuboCop will use this path to determine which cops are enabled (via eg. Include/Exclude), and so that certain cops like Naming/FileName can be checked.

@coneybeare
Copy link
Contributor Author

After debugging further, it appears the problem stems from spaces in the document.uri. Because this is a valid file path on many OS's, (and one that cannot be changed in my specific use case), I will open a PR that will place the document.uri in single quotes

@wingrunr21
Copy link
Collaborator

That's the wrong formatter if you are using the language server, FYI

@github-actions
Copy link

github-actions bot commented Sep 7, 2020

This issue has not had activity for 30 days. It will be automatically closed in 7 days.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants