Vscode-ruby: Long RuboCop/Standard output JSON does not parse correctly

Created on 21 Feb 2019  路  23Comments  路  Source: rubyide/vscode-ruby

Your environment

  • vscode-ruby version: 0.22.0
  • Ruby version: 2.1.2
  • Ruby version manager (if any): asdf 0.6.3
  • VS Code version: 1.31.1
  • Operating System: Mac OS 10.14.3
  • Using language server? Yes

Expected behavior

Rubocop will lint a file

Actual behavior

Rubocop doesn't lint a file. And I have next error in Ruby language server output:

[Info  - 2:30:00 PM] Initializing Ruby language server...
[Info  - 2:30:00 PM] Rebuilding tree-sitter for local Electron version
[Info  - 2:30:00 PM] Rebuild succeeded!
Lint: executing rubocop -s <path_to_file> -f json -R -l...
/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/rxjs/internal/util/hostReportError.js:4
    setTimeout(function () { throw err; });
                             ^

TypeError: LINTER_MAP[name] is not a constructor
    at getLinter (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/server/out/Linter.js:24:12)
    at MergeMapSubscriber.rxjs_1.from.pipe.operators_1.mergeMap.l [as project] (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/server/out/Linter.js:31:37)
    at MergeMapSubscriber._tryNext (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/rxjs/internal/operators/mergeMap.js:69:27)
    at MergeMapSubscriber._next (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/rxjs/internal/operators/mergeMap.js:59:18)
    at MergeMapSubscriber.Subscriber.next (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/rxjs/internal/Subscriber.js:66:18)
    at Observable._subscribe (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/rxjs/internal/util/subscribeToArray.js:5:20)
    at Observable._trySubscribe (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/rxjs/internal/Observable.js:44:25)
    at Observable.subscribe (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/rxjs/internal/Observable.js:30:22)
    at MergeMapOperator.call (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/rxjs/internal/operators/mergeMap.js:39:23)
    at Observable.subscribe (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/server/node_modules/rxjs/internal/Observable.js:25:31)
[Info  - 2:30:01 PM] Connection to server got closed. Server will restart.
[Error - 2:30:01 PM] Request textDocument/foldingRange failed.
Error: Connection got disposed.
    at Object.dispose (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/main.js:876:25)
    at Object.dispose (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-languageclient/lib/client.js:71:35)
    at LanguageClient.handleConnectionClosed (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-languageclient/lib/client.js:2150:42)
    at LanguageClient.handleConnectionClosed (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-languageclient/lib/main.js:150:15)
    at closeHandler (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-languageclient/lib/client.js:2137:18)
    at CallbackList.invoke (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/events.js:120:36)
    at closeHandler (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/main.js:226:26)
    at CallbackList.invoke (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/events.js:62:39)
    at Emitter.fire (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/events.js:120:36)
    at IPCMessageReader.fireClose (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/messageReader.js:111:27)
    at ChildProcess.constructor.eventEmitter.on (/Users/shir/.vscode/extensions/rebornix.ruby-0.22.0/client/node_modules/vscode-jsonrpc/lib/messageReader.js:213:45)
    at ChildProcess.emit (events.js:187:15)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)

And this message appears several times

bug

All 23 comments

Plugin configuration:

{
  "ruby.intellisense": "rubyLocate",
  "ruby.interpreter.commandPath": "/Users/shir/.asdf/shims/ruby",
  "ruby.lint": {
    "rubocop": {
      "lint": true,
      "rails": true,
    },
    "ruby": true,
  },
  "ruby.useLanguageServer": true,
  "ruby.useBundler": true,
  "ruby.pathToBundler": "/Users/shir/.asdf/shims/bundle"
}

Can you post your configuration?

Great thanks!

@wingrunr21 see above

If you remove the Ruby lint entry does the error resolve? It鈥檚 redundant with rubocop and I鈥檓 not supporting it in the language server.

@wingrunr21 yes. Error have disappeared. But have next message in logs and I don't see lint errors:

Lint: executing rubocop -s <path_to_file> -f json -R -l...
Lint: Received invalid JSON from rubocop:

No such plugin: ruby

Is it because of old rubocop version (0.57.2)? I can't use more modern rubocop because this version is last which supports ruby 2.1

nevermind. Look like it's an issue with asdf which I use as ruby version manager

Ah, mind telling me what the issue is? I'd like to support that if I can

@wingrunr21 rubocop is run via asdf as a shim. Asdf determine which ruby version to use based on the current working directory and .ruby-version file in this directory. Maybe the issue is that the rubocop is run not within the project directory. Which directory do you use to run rubocop?

Is the .ruby-version file in the workspace root? That's where the environment detection spawns a shell to see what the ruby environment should be in that directory.

How does asdf expose which ruby to run? Does it modify the environment?

I made some debugging. Looks like when rubocop is called no environment variable are set. asdf depends on $HOME variable to set asdf data directory but $HOME is empty and the data directory is set to /.asdf instead ~/.asdf. And it can't find any installed plugins. Theoretically, it may be set via setting ASDF_DATA_DIR environment variable but I don't know how to set it in this case.

In a normal environment, this variable (with other configs) is set via a special script which is called from .bashrc/.bash_profile.

Could you provide the ability to set custom environment variables for linters? I believe it will also allow to fix any issues with running rubocop with rvm too.

The environment variables need to be whitelisted into the environment detection

HOME is now whitelisted on v0.22.1. Can you see if that works for you?

I've updated to 0.22.1 and still don't see any value for HOME variable within asdf scripts. I've tried to output env command and here is a result:

PWD=<path_to_project>
SHLVL=1
_=/usr/bin/env

Not sure why this happens. I don't even see PATH variable here. (but if I output PATH variable it shows /usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.)

Looks like something is wrong with setting env variable. When I output this.config.env before a linter process spawn in the plugin it shows {}.

Ok, your original issue of LINTER_MAP[name] is not a constructor is fixed in v0.22.2.

Would you mind giving that version another try for your RuboCop linting? I made some additional changes to the environment detection.

If that doesn't work, are you using a shell that's different from your user's default shell?

@wingrunr21 now rubocop run successfully but I have a error about invalid json. But output json seems legit to me.

[Info  - 11:15:47 AM] Initializing Ruby language server...
[Info  - 11:15:47 AM] Rebuilding tree-sitter for local Electron version
[Info  - 11:15:47 AM] Rebuild succeeded!
Lint: executing rubocop -s <path_to_file> -f json...
Lint: Received invalid JSON from rubocop:

{"metadata":{"rubocop_version":"0.65.0","ruby_engine":"ruby","ruby_version":"2.3.8","ruby_patchlevel":"459","ruby_platform":"x86_64-darwin18"},"files":[{"path":"<path_to_file>","offenses":[{"severity":"convention","message":"Metrics/ClassLength: Class has too many lines. [102/100]","cop_name":"Metrics/ClassLength","corrected":false,"location":{"start_line":1,"start_column":1,"last_line":151,"last_column":3,"length":5690,"line":1,"column":1}},{"severity":"convention","message":"Style/Documentation: Missing top-level class documentation comment.","cop_name":"Style/Documentation","corrected":false,"location":{"start_line":1,"start_column":1,"last_line":1,"last_column":5,"length":5,"line":1,"column":1}},{"severity":"convention","message":"Style/FrozenStringLiteralComment: Missing magic comment `# frozen_string_literal: true`.","cop_name":"Style/FrozenStringLiteralComment","corrected":false,"location":{"start_line":1,"start_column":1,"last_line":1,"last_column":1,"length":1,"line":1,"column":1}},{"severity":"convention","message":"Metrics/AbcSize: Assignment Branch Condition size for perform is too high. [124.1/15]","cop_name":"Metrics/AbcSize","corrected":false,"location":{"start_line":13,"start_column":3,"last_line":150,"last_column":5,"length":5446,"line":13,"column":3}},{"severity":"convention","message":"Metrics/CyclomaticComplexity: Cyclomatic complexity for perform is too high. [19/6]","cop_name":"Metrics/CyclomaticComplexity","corrected":false,"location":{"start_line":13,"start_column":3,"last_line":150,"last_column":5,"length":5446,"line":13,"column":3}},{"severity":"convention","message":"Metrics/MethodLength: Method has too many lines. [92/10]","cop_name":"Metrics/MethodLength","corrected":false,"location":{"start_line":13,"start_column":3,"last_line":150,"last_column":5,"length":5446,"line":13,"column":3}},{"severity":"convention","message":"Metrics/PerceivedComplexity: Perceived complexity for perform is too high. [18/7]","cop_name":"Metrics/PerceivedComplexity","corrected":false,"location":{"start_line":13,"start_column":3,"last_line":150,"last_column":5,"length":5446,"line":13,"column":3}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [81/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":16,"start_column":81,"last_line":16,"last_column":81,"length":1,"line":16,"column":81}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [84/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":17,"start_column":81,"last_line":17,"last_column":84,"length":4,"line":17,"column":81}},{"severity":"convention","message":"Style/RescueModifier: Avoid using `rescue` in its modifier form.","cop_name":"Style/RescueModifier","corrected":false,"location":{"start_line":22,"start_column":22,"last_line":22,"last_column":48,"length":27,"line":22,"column":22}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [85/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":26,"start_column":81,"last_line":26,"last_column":85,"length":5,"line":26,"column":81}},{"severity":"convention","message":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"location":{"start_line":29,"start_column":29,"last_line":29,"last_column":37,"length":9,"line":29,"column":29}},{"severity":"convention","message":"Style/RescueModifier: Avoid using `rescue` in its modifier form.","cop_name":"Style/RescueModifier","corrected":false,"location":{"start_line":34,"start_column":8,"last_line":34,"last_column":44,"length":37,"line":34,"column":8}},{"severity":"warning","message":"Lint/UnderscorePrefixedVariableName: Do not use prefix `_` for a variable that is used.","cop_name":"Lint/UnderscorePrefixedVariableName","corrected":false,"location":{"start_line":39,"start_column":43,"last_line":39,"last_column":43,"length":1,"line":39,"column":43}},{"severity":"warning","message":"Lint/UnderscorePrefixedVariableName: Do not use prefix `_` for a variable that is used.","cop_name":"Lint/UnderscorePrefixedVariableName","corrected":false,"location":{"start_line":39,"start_column":46,"last_line":39,"last_column":47,"length":2,"line":39,"column":46}},{"severity":"convention","message":"Style/StringLiteralsInInterpolation: Prefer single-quoted strings inside interpolations.","cop_name":"Style/StringLiteralsInInterpolation","corrected":false,"location":{"start_line":44,"start_column":43,"last_line":44,"last_column":45,"length":3,"line":44,"column":43}},{"severity":"convention","message":"Style/DoubleNegation: Avoid the use of double negation (`!!`).","cop_name":"Style/DoubleNegation","corrected":false,"location":{"start_line":48,"start_column":11,"last_line":48,"last_column":11,"length":1,"line":48,"column":11}},{"severity":"convention","message":"Style/RescueModifier: Avoid using `rescue` in its modifier form.","cop_name":"Style/RescueModifier","corrected":false,"location":{"start_line":48,"start_column":11,"last_line":48,"last_column":45,"length":35,"line":48,"column":11}},{"severity":"convention","message":"Layout/ExtraSpacing: Unnecessary spacing detected.","cop_name":"Layout/ExtraSpacing","corrected":false,"location":{"start_line":48,"start_column":50,"last_line":48,"last_column":55,"length":6,"line":48,"column":50}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [97/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":48,"start_column":81,"last_line":48,"last_column":97,"length":17,"line":48,"column":81}},{"severity":"convention","message":"Layout/MultilineOperationIndentation: Align the operands of a condition in an `if` statement spanning multiple lines.","cop_name":"Layout/MultilineOperationIndentation","corrected":false,"location":{"start_line":49,"start_column":9,"last_line":49,"last_column":33,"length":25,"line":49,"column":9}},{"severity":"convention","message":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"location":{"start_line":49,"start_column":30,"last_line":49,"last_column":32,"length":3,"line":49,"column":30}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [101/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":49,"start_column":81,"last_line":49,"last_column":101,"length":21,"line":49,"column":81}},{"severity":"convention","message":"Layout/MultilineOperationIndentation: Align the operands of a condition in an `if` statement spanning multiple lines.","cop_name":"Layout/MultilineOperationIndentation","corrected":false,"location":{"start_line":50,"start_column":9,"last_line":50,"last_column":39,"length":31,"line":50,"column":9}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [96/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":50,"start_column":81,"last_line":50,"last_column":96,"length":16,"line":50,"column":81}},{"severity":"convention","message":"Layout/MultilineOperationIndentation: Align the operands of a condition in an `if` statement spanning multiple lines.","cop_name":"Layout/MultilineOperationIndentation","corrected":false,"location":{"start_line":51,"start_column":9,"last_line":51,"last_column":54,"length":46,"line":51,"column":9}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [99/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":51,"start_column":81,"last_line":51,"last_column":99,"length":19,"line":51,"column":81}},{"severity":"convention","message":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"location":{"start_line":53,"start_column":22,"last_line":53,"last_column":24,"length":3,"line":53,"column":22}},{"severity":"convention","message":"Layout/TrailingWhitespace: Trailing whitespace detected.","cop_name":"Layout/TrailingWhitespace","cor
Lint: Received invalid JSON from rubocop:

rected":false,"location":{"start_line":60,"start_column":54,"last_line":60,"last_column":54,"length":1,"line":60,"column":54}},{"severity":"convention","message":"Layout/MultilineOperationIndentation: Align the operands of an expression in an assignment spanning multiple lines.","cop_name":"Layout/MultilineOperationIndentation","corrected":false,"location":{"start_line":61,"start_column":7,"last_line":61,"last_column":91,"length":85,"line":61,"column":7}},{"severity":"convention","message":"Layout/SpaceBeforeBlockBraces: Space missing to the left of {.","cop_name":"Layout/SpaceBeforeBlockBraces","corrected":false,"location":{"start_line":61,"start_column":31,"last_line":61,"last_column":31,"length":1,"line":61,"column":31}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [91/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":61,"start_column":81,"last_line":61,"last_column":91,"length":11,"line":61,"column":81}},{"severity":"convention","message":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"location":{"start_line":65,"start_column":39,"last_line":65,"last_column":51,"length":13,"line":65,"column":39}},{"severity":"convention","message":"Metrics/BlockLength: Block has too many lines. [42/25]","cop_name":"Metrics/BlockLength","corrected":false,"location":{"start_line":66,"start_column":5,"last_line":126,"last_column":7,"length":2381,"line":66,"column":5}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [94/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":66,"start_column":81,"last_line":66,"last_column":94,"length":14,"line":66,"column":81}},{"severity":"convention","message":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"location":{"start_line":66,"start_column":81,"last_line":66,"last_column":83,"length":3,"line":66,"column":81}},{"severity":"convention","message":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"location":{"start_line":68,"start_column":17,"last_line":68,"last_column":94,"length":78,"line":68,"column":17}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [94/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":68,"start_column":81,"last_line":68,"last_column":94,"length":14,"line":68,"column":81}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [99/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":71,"start_column":81,"last_line":71,"last_column":99,"length":19,"line":71,"column":81}},{"severity":"convention","message":"Layout/TrailingWhitespace: Trailing whitespace detected.","cop_name":"Layout/TrailingWhitespace","corrected":false,"location":{"start_line":74,"start_column":1,"last_line":74,"last_column":8,"length":8,"line":74,"column":1}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [100/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":78,"start_column":81,"last_line":78,"last_column":100,"length":20,"line":78,"column":81}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [83/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":90,"start_column":81,"last_line":90,"last_column":83,"length":3,"line":90,"column":81}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [107/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":93,"start_column":81,"last_line":93,"last_column":107,"length":27,"line":93,"column":81}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [105/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":108,"start_column":81,"last_line":108,"last_column":105,"length":25,"line":108,"column":81}},{"severity":"convention","message":"Layout/CaseIndentation: Indent `when` as deep as `case`.","cop_name":"Layout/CaseIndentation","corrected":false,"location":{"start_line":113,"start_column":19,"last_line":113,"last_column":22,"length":4,"line":113,"column":19}},{"severity":"convention","message":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"location":{"start_line":114,"start_column":21,"last_line":114,"last_column":25,"length":5,"line":114,"column":21}},{"severity":"convention","message":"Layout/CaseIndentation: Indent `when` as deep as `case`.","cop_name":"Layout/CaseIndentation","corrected":false,"location":{"start_line":115,"start_column":19,"last_line":115,"last_column":22,"length":4,"line":115,"column":19}},{"severity":"convention","message":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"location":{"start_line":115,"start_column":24,"last_line":115,"last_column":25,"length":2,"line":115,"column":24}},{"severity":"convention","message":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"location":{"start_line":116,"start_column":21,"last_line":116,"last_column":27,"length":7,"line":116,"column":21}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [104/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":135,"start_column":81,"last_line":135,"last_column":104,"length":24,"line":135,"column":81}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [97/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":137,"start_column":81,"last_line":137,"last_column":97,"length":17,"line":137,"column":81}},{"severity":"convention","message":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"location":{"start_line":137,"start_column":84,"last_line":137,"last_column":86,"length":3,"line":137,"column":84}},{"severity":"convention","message":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"location":{"start_line":138,"start_column":17,"last_line":138,"last_column":52,"length":36,"line":138,"column":17}},{"severity":"convention","message":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","cop_name":"Style/StringLiterals","corrected":false,"location":{"start_line":142,"start_column":17,"last_line":142,"last_column":52,"length":36,"line":142,"column":17}},{"severity":"convention","message":"Metrics/LineLength: Line is too long. [83/80]","cop_name":"Metrics/LineLength","corrected":false,"location":{"start_line":146,"start_column":81,"last_line":146,"last_column":83,"length":3,"line":146,"column":81}}]}],"summary":{"offense_count":55,"target_file_count":1,"inspected_file_count":1}}

If I add settings to enable only lint and rails:

{
  "ruby.lint": {
    "rubocop": {
      "lint": true,
      "rails": true,
    }
  },
  "ruby.useLanguageServer": true,
}

then I don't have any errors and see rubocop errors in vscode but only a few (2 instead 55 like in json above). Look like not all rules are applied.

I've outputted error on JSON parse (BTW, I think it will be useful for debugging to show it by default but not only "Lint: Received invalid JSON from rubocop") and get next errors:

e:  SyntaxError: Unexpected end of JSON input
e:  SyntaxError: Unexpected token h in JSON at position 1
e:  SyntaxError: Unexpected token , in JSON at position 0

Looks like a rubocop output is split into several chunks and is not later combined in one whole.

fwiw, I'm seeing the same error as above ^.

Lint: Received invalid JSON from rubocop:

{"metadata":{"rubocop_version":"0.65.0","ruby_engine":"ruby","ruby_version":"2.3.3","ruby_patchlevel":"222","ruby_platform":"x86_64-darwin15"},"files":[{"path":"config/initializers/cors.rb","offenses":[{"severity":"convention","message":"Metrics/BlockLength:
.....

vscode-ruby: 0.22.2
rvm: 1.29.3
vscode: 1.31.1
mac os: 10.14.1

It will lint as expected on files with only a few offenses, but when there are many, it throws this error.

Ya, I've traced this to stdout being chunked back into the node process. I'll have to implement a buffer to the output so the whole JSON response can be parsed at once.

v0.22.3 has the bugfix for this

@wingrunr21 now everything works as expected. Thank you a lot!

Great! Thanks for all your help and patience working through these bugs!

Was this page helpful?
0 / 5 - 0 ratings