diff --git a/lib/ruby_lsp/requests/support/rubocop_runner.rb b/lib/ruby_lsp/requests/support/rubocop_runner.rb index 1dc0041e92..0a15e5f527 100644 --- a/lib/ruby_lsp/requests/support/rubocop_runner.rb +++ b/lib/ruby_lsp/requests/support/rubocop_runner.rb @@ -81,7 +81,7 @@ def initialize(*args) @offenses = [] #: Array[::RuboCop::Cop::Offense] @errors = [] #: Array[String] @warnings = [] #: Array[String] - @prism_result = nil #: Prism::ParseLexResult? + # @prism_result = nil #: Prism::ParseLexResult? args += DEFAULT_ARGS rubocop_options = ::RuboCop::Options.new.parse(args).first @@ -101,7 +101,11 @@ def run(path, contents, prism_result) @warnings = [] @offenses = [] @options[:stdin] = contents - @prism_result = prism_result + + # Setting the Prism result before running the RuboCop runner makes it reuse the existing AST and avoids + # double-parsing. Unfortunately, this leads to a bunch of cops failing to execute properly under LSP mode. + # Uncomment this once reusing the Prism result is more stable + # @prism_result = prism_result super([path])