123456789_123456789_123456789_123456789_123456789_

Module: RuboCop::Server Private

Overview

The bootstrap module for server.

Constant Summary

Class Attribute Summary

Class Method Summary

Class Attribute Details

.running?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rubocop/server.rb', line 38

def running?
  return false unless support_server? # Never running.

  Cache.pid_running?
end

.support_server?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rubocop/server.rb', line 34

def support_server?
  RUBY_ENGINE == 'ruby' && !RuboCop::Platform.windows?
end

Class Method Details

.forward_to_server?(argv = ARGV) ⇒ Boolean

Whether the invocation should be forwarded to the running server process. --lsp and --mcp always run in the current process even when the server is running: they serve a protocol on stdio, which the server’s exec command cannot do.

[ GitHub ]

  
# File 'lib/rubocop/server.rb', line 47

def forward_to_server?(argv = ARGV)
  return false unless running?

  (IN_PROCESS_PROTOCOL_OPTIONS & argv).empty?
end

.wait_for_running_status!(expected)

[ GitHub ]

  
# File 'lib/rubocop/server.rb', line 53

def wait_for_running_status!(expected)
  start_time = Time.now
  while Server.running? != expected
    sleep 0.1
    next unless Time.now - start_time > TIMEOUT

    warn "running? was not #{expected} after #{TIMEOUT} seconds!"
    exit 1
  end
end