Sha256: d2195eb46c6f3305c9316fcae07dc8a168bd74b23bdf81a6b3977aeae3b1c1b3
Contents?: true
Size: 1.33 KB
Versions: 10
Compression:
Stored size: 1.33 KB
Contents
# typed: strict # frozen_string_literal: true require "ruby_lsp/requests/support/rubocop_diagnostics_runner" module RubyLsp module Requests #  # # The # [diagnostics](https://microsoft.github.io/language-server-protocol/specification#textDocument_publishDiagnostics) # request informs the editor of RuboCop offenses for a given file. # # # Example # # ```ruby # def say_hello # puts "Hello" # --> diagnostics: incorrect indentation # end # ``` class Diagnostics < BaseRequest extend T::Sig sig { params(document: Document).void } def initialize(document) super(document) @uri = T.let(document.uri, String) end sig { override.returns(T.nilable(T.all(T::Array[Support::RuboCopDiagnostic], Object))) } def run # Running RuboCop is slow, so to avoid excessive runs we only do so if the file is syntactically valid return if @document.syntax_error? return unless defined?(Support::RuboCopDiagnosticsRunner) # Don't try to run RuboCop diagnostics for files outside the current working directory return unless URI(@uri).path&.start_with?(T.must(WORKSPACE_URI.path)) Support::RuboCopDiagnosticsRunner.instance.run(@uri, @document) end end end end
Version data entries
10 entries across 10 versions & 1 rubygems