Skip to content

Internal errors occurring for various Layout/* cops #2840

@davidcelis

Description

@davidcelis

Description

Ruby LSP Information

Ruby LSP Information

VS Code Version

1.95.1

Ruby LSP Extension Version

0.8.13

Ruby LSP Server Version

0.21.3

Ruby LSP Addons

  • Standard Ruby
  • Ruby LSP Rails

Ruby Version

3.1.4

Ruby Version Manager

asdf

Installed Extensions

Click to expand
  • atom-keybindings (3.3.0)
  • azure-repos (0.40.0)
  • cel (0.1.2)
  • circleci (2.8.4)
  • copilot (1.243.0)
  • copilot-chat (0.22.1)
  • even-better-toml (0.19.2)
  • github-vscode-theme (6.3.5)
  • gitlens (15.6.3)
  • go (0.42.1)
  • makefile-tools (0.11.13)
  • markdown-all-in-one (3.6.2)
  • remote-containers (0.388.0)
  • remote-repositories (0.42.0)
  • remotehub (0.64.0)
  • ruby-lsp (0.8.13)
  • sorbet-vscode-extension (0.3.37)
  • terraform (2.33.0)
  • vscode-buf (0.6.2)
  • vscode-docker (1.29.3)
  • vscode-graphql (0.12.1)
  • vscode-graphql-syntax (1.3.8)
  • vscode-jsonnet (0.7.2)
  • vscode-mdx (1.8.11)
  • vscode-proto3 (0.5.5)
  • vscode-pull-request-github (0.100.0)
  • vscode-tailwindcss (0.12.12)
  • vscode-yaml (1.15.0)

Ruby LSP Settings

Click to expand
Workspace
{
  "formatter": "rubocop",
  "linters": [
    "rubocop"
  ]
}
User
{
  "enableExperimentalFeatures": false,
  "enabledFeatures": {
    "codeActions": true,
    "diagnostics": true,
    "documentHighlights": true,
    "documentLink": true,
    "documentSymbols": true,
    "foldingRanges": true,
    "formatting": true,
    "hover": true,
    "inlayHint": true,
    "onTypeFormatting": true,
    "selectionRanges": true,
    "semanticHighlighting": true,
    "completion": true,
    "codeLens": true,
    "definition": true,
    "workspaceSymbol": true,
    "signatureHelp": true,
    "typeHierarchy": true,
    "references": true
  },
  "featuresConfiguration": {},
  "addonSettings": {},
  "rubyVersionManager": {
    "identifier": "auto"
  },
  "customRubyCommand": "",
  "formatter": "rubocop",
  "linters": [
    "rubocop"
  ],
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "",
  "indexing": {},
  "erbSupport": true,
  "useLauncher": false,
  "featureFlags": {}
}

Reproduction steps

  1. Start Ruby LSP with VSCode
  2. Open a Ruby file
  3. Change a line's indentation so it does not share the same indentation level as the code surrounding it
  4. See an error dialogue:

Error running diagnostics: An internal error occurred for the Layout/IndentationConsistency cop. Updating to a newer version of RuboCop may solve this. For more details, run RuboCop on the command line.

Other Layout/* cops that come standard with StandardRB experience the same issue. Ones I've seen include:

  • Layout/IndentationConsistency
  • Layout/FirstArrayElementIndentation
  • Layout/IndentationWidth

I haven't seen any other cops cause this issue. For instance, with the below code snippet, I can change the strings at the end of the file to use single quotes and they will display inline linting issues correctly and the file will automatically format/fix on save. However, if I add extra indentation to practically any line, I get diagnostic or formatting errors with no other information.

Example code

class NotClass < BasicObject
  instance_methods.grep(/^[^_]/).each { |m| undef_method m }

  def initialize(object)
    @object = object
  end

  def method_missing(name, ...)
    !@object.send(name, ...)
  end

  def respond_to_missing?(name, include_private = false)
    @object.respond_to?(name, include_private)
  end
end

class Object
  def not = NotClass.new(self)
end

puts nil.not.nil?
puts 1.not.eql?(2)
puts [1, 3, 5, 7, 9].not.any? { |i| i % 2 == 0 }
puts "hello".not.start_with?("h")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingvscodeThis pull request should be included in the VS Code extension's release notes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions