misogi / vscode-ruby-rubocop

Rubocop extension for Visual Studio Code
https://marketplace.visualstudio.com/items/misogi.ruby-rubocop
MIT License
137 stars 68 forks source link

Error on autocorrect with rubocop >=0.91 #129

Closed yupswing closed 4 years ago

yupswing commented 4 years ago

I noticed an error on autocorrect (Format document) if, and only if, rubocop version is >= 0.91

With version prior to 0.91 everything works fine.

My system

Version: 1.49.1
Commit: 58bb7b2331731bf72587010e943852e13e6fd3cf
Date: 2020-09-23T22:26:38.399Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Linux x64 5.4.68-1-lts

vscode-ruby-rubocop: 0.8.4

ruby: 2.7.1

Here's the error from the Extension Host Log

[2020-10-01 14:46:11.698] [exthost] [error] [misogi.ruby-rubocop] provider FAILED
[2020-10-01 14:46:11.699] [exthost] [error] Error: Error parsing autocorrection from CLI: {"metadata":{"rubocop_version":"0.91.0","ruby_engine":"ruby","ruby_version":"2.7.1","ruby_patchlevel":"83","ruby_platform":"x86_64-linux"},"files":[{"path":"/home/yupswing/dev/project-server/app/models/user.rb","offenses":[{"severity":"convention","message":"Class has too many lines. [146/100]","cop_name":"Metrics/ClassLength","corrected":false,"correctable":false,"location":{"start_line":38,"start_column":1,"last_line":259,"last_column":3,"length":6944,"line":38,"column":1}},{"severity":"convention","message":"Prefer single-quoted strings when you don't need string interpolation or special symbols. (https://rubystyle.guide#consistent-string-literals)","cop_name":"Style/StringLiterals","corrected":true,"correctable":true,"location":{"start_line":51,"start_column":33,"last_line":51,"last_column":45,"length":13,"line":51,"column":33}},{"severity":"convention","message":"Cyclomatic complexity for stats is too high. [8/7]","cop_name":"Metrics/CyclomaticComplexity","corrected":false,"correctable":false,"location":{"start_line":211,"start_column":3,"last_line":258,"last_column":5,"length":1790,"line":211,"column":3}},{"severity":"convention","message":"Line is too long. [136/120] (https://rubystyle.guide#max-line-length)","cop_name":"Layout/LineLength","corrected":false,"correctable":true,"location":{"start_line":215,"start_column":121,"last_line":215,"last_column":136,"length":16,"line":215,"column":121}}]}],"summary":{"offense_count":4,"target_file_count":1,"inspected_file_count":1}}
    at RubocopAutocorrectProvider.onSuccess (/home/yupswing/.vscode-oss/extensions/misogi.ruby-rubocop-0.8.4/out/src/rubocop.js:54:19)
    at RubocopAutocorrectProvider.provideDocumentFormattingEdits (/home/yupswing/.vscode-oss/extensions/misogi.ruby-rubocop-0.8.4/out/src/rubocop.js:38:29)
    at /usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:718:265
    at /usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:52:373
    at new Promise (<anonymous>)
    at Object.t.asPromise (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:52:345)
    at T.provideDocumentFormattingEdits (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:718:236)
    at /usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:738:230
    at K._withAdapter (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:732:331)
    at K.$provideDocumentFormattingEdits (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:738:208)
    at g._doInvokeHandler (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:860:464)
    at g._invokeHandler (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:860:156)
    at g._receiveRequest (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:858:766)
    at g._receiveOneMessage (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:857:623)
    at /usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:855:691
    at l.fire (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:475)
    at v.fire (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:256:381)
    at /usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1047:649
    at l.fire (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:475)
    at v.fire (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:256:381)
    at t.PersistentProtocol._receiveMessage (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:261:451)
    at /usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:258:489
    at l.fire (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:46:475)
    at p.acceptChunk (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:253:851)
    at /usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:253:203
    at Socket.t (/usr/lib/code/out/vs/workbench/services/extensions/node/extensionHostProcess.js:263:54)
    at Socket.emit (events.js:223:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:181:23)
ngouy commented 4 years ago

@misogi the issue is that rubocop doesn't anymore uses a tons of (wtf) equal sign in their message API : image

But we hardcheck for these equal signs : image

I tried to remove them and check on my machine but vs code detect a corrupted extension ... so I can't just test it out

ngouy commented 4 years ago

breaking change found : https://github.com/rubocop-hq/rubocop/commit/3282218b87e806b9793fca7480e1f1275821584a

Its a fix of a long ongoing bug that was handled "a la main" here, but doesn't works anymore as the bug is fixed