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

RuboCop "except" argument crashes linter when using language server #459

Closed
liq2519 opened this issue Mar 19, 2019 · 1 comment
Closed
Assignees
Labels
bug Bug reports

Comments

@liq2519
Copy link

liq2519 commented Mar 19, 2019

Your environment

  • vscode-ruby version: 0.22.3

  • Ruby version: 2.2.4

  • Ruby version manager (if any): None

  • VS Code version: 1.32.3

  • Operating System: Windows 10.0.16299 Build 16299

  • Using language server? Yes

Expected behavior

RuboCop linter functions normally using language server.

Actual behavior

Switched to using language server because of issue #262. Looks like rubocop was trying to find the excepted cops in the project folder rather than the correct directory.

Error message in "Output/Ruby Language Server":

[Info  - 5:58:08 PM] Initializing Ruby language server...
[Info  - 5:58:08 PM] Rebuilding tree-sitter for local Electron version
[Info  - 5:58:08 PM] Rebuild succeeded!
Lint: executing rubocop.bat -s c:\tmp\test.rb -f json --except c:\tmp\Style\AsciiComments...
Lint: Received invalid JSON from rubocop:

Unrecognized cop or department: c:\tmp\Style\AsciiComments.
{"metadata":{"rubocop_version":"0.54.0","ruby_engine":"ruby","ruby_version":"2.2.4","ruby_patchlevel":"230","ruby_platform":"x64-mingw32"},"files":[],"summary":{"offense_count":0,"target_file_count":1,"inspected_file_count":0}}

Workspace setting:

{
    "ruby.lint": {
        "rubocop": {
            "except": ["Style/AsciiComments"]
        }
    },
    "ruby.useLanguageServer": true
}

This issue may be independent from scripts. A simple one that can reproduce the error:

# Comments with non-ascii character: ©

@wingrunr21
Copy link
Collaborator

Yep, this is a bug. Looks like I accidentally treated the except and only CLI args as file filters instead of cop filters. I'll get this fixed.

Workaround in the mean time is to put this exception into your configuration file.

@wingrunr21 wingrunr21 self-assigned this Mar 19, 2019
@wingrunr21 wingrunr21 added the bug Bug reports label Mar 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug reports
Projects
None yet
Development

No branches or pull requests

2 participants