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

Rubocop requires relative paths #641

Closed
@coneybeare

Description

@coneybeare

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions