Sha256: 4c571d86c5eb0a0649675e0130ce4311e1f593ecd3888cf34a72d9b9ea6f3c6c

Contents?: true

Size: 886 Bytes

Versions: 12

Compression:

Stored size: 886 Bytes

Contents

# typed: strict
# frozen_string_literal: true

return unless defined?(RubyLsp::Requests::Support::RuboCopRunner)

require "singleton"

module RubyLsp
  module Requests
    module Support
      # :nodoc:
      class RuboCopDiagnosticsRunner
        extend T::Sig
        include Singleton

        sig { void }
        def initialize
          @runner = T.let(RuboCopRunner.new, RuboCopRunner)
        end

        sig { params(uri: URI::Generic, document: Document).returns(T::Array[Support::RuboCopDiagnostic]) }
        def run(uri, document)
          filename = T.must(uri.to_standardized_path || uri.opaque)
          # Invoke RuboCop with just this file in `paths`
          @runner.run(filename, document.source)

          @runner.offenses.map do |offense|
            Support::RuboCopDiagnostic.new(document, offense, uri)
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ruby-lsp-0.15.0 lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
ruby-lsp-0.14.6 lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
ruby-lsp-0.14.5 lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
ruby-lsp-0.14.4 lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
ruby-lsp-0.14.3 lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
ruby-lsp-0.14.2 lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
ruby-lsp-0.14.1 lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
ruby-lsp-0.14.0 lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
ruby-lsp-0.13.4 lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
ruby-lsp-0.13.3 lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
ruby-lsp-0.13.2 lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb
ruby-lsp-0.13.1 lib/ruby_lsp/requests/support/rubocop_diagnostics_runner.rb