为什么我在 VSCODE 中出现解析输出错误(它可能是非 JSON 输出)

Why i get Error on parsing output (It might non-JSON output) in VSCODE

安装 Rubocop 扩展后。我在 VS 代码中收到此警报的警告。

Error on parsing output (It might non-JSON output) : "{"metadata":{"rubocop_version":"0.52.1","ruby_engine":"ruby","ruby_version":"2.4.1","ruby_patchlevel"

这是我的文件工作区设置

{
    "ruby.rubocop.executePath": "/Users/foo/.rvm/gems/ruby-2.4.1/bin/",
    "ruby.rubocop.configFilePath": "/Users/foo/git/project_name/.rubocop.yml",
    "ruby.rubocop.onSave": true
}

此内容在文件 .rubocop.yml

AllCops:
  Exclude:
    - 'vendor/**/*'
    - 'spec/fixtures/**/*'
    - 'tmp/**/*'
    - 'db/schema.rb'
    - 'db/migrate/**/*'
    - 'lib/tasks/**/*'

我遇到了这个错误,问题是代码中有太多“违规行为”。

解决方案是从命令行 运行 rubocop 并更正足够的违规行为,直到它可以被扩展管理。我用 rubocop —auto-correct filename.rb 纠正了很多错误。

我看到其他人在 GitHub VS Code ruby-rubocop 扩展的问题跟踪器上使用不同的解决方案来解决此错误。