Skip to content

Commit 558c9c5

Browse files
committed
Use $stderr.puts instead of warn
1 parent 734259e commit 558c9c5

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ Sorbet/StrictSigil:
3737
- "test/**/*.rb"
3838

3939
Style/StderrPuts:
40-
Enabled: true
40+
Enabled: false

lib/ruby_lsp/ruby_lsp_rails/runner_client.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class << self
1414
def create_client
1515
new
1616
rescue Errno::ENOENT, StandardError => e # rubocop:disable Lint/ShadowedException
17-
warn("Ruby LSP Rails failed to initialize server: #{e.message}\n#{e.backtrace&.join("\n")}")
18-
warn("Server dependent features will not be available")
17+
$stderr.puts("Ruby LSP Rails failed to initialize server: #{e.message}\n#{e.backtrace&.join("\n")}")
18+
$stderr.puts("Server dependent features will not be available")
1919
NullClient.new
2020
end
2121
end
@@ -50,14 +50,14 @@ def initialize
5050
@stdin.binmode # for Windows compatibility
5151
@stdout.binmode # for Windows compatibility
5252

53-
warn("Ruby LSP Rails booting server")
53+
$stderr.puts("Ruby LSP Rails booting server")
5454
read_response
55-
warn("Finished booting Ruby LSP Rails server")
55+
$stderr.puts("Finished booting Ruby LSP Rails server")
5656

5757
unless ENV["RAILS_ENV"] == "test"
5858
at_exit do
5959
if @wait_thread.alive?
60-
warn("Ruby LSP Rails is force killing the server")
60+
$stderr.puts("Ruby LSP Rails is force killing the server")
6161
sleep(0.5) # give the server a bit of time if we already issued a shutdown notification
6262
Process.kill(T.must(Signal.list["TERM"]), @wait_thread.pid)
6363
end
@@ -71,22 +71,22 @@ def initialize
7171
def model(name)
7272
make_request("model", name: name)
7373
rescue IncompleteMessageError
74-
warn("Ruby LSP Rails failed to get model information: #{@stderr.read}")
74+
$stderr.puts("Ruby LSP Rails failed to get model information: #{@stderr.read}")
7575
nil
7676
end
7777

7878
sig { void }
7979
def trigger_reload
80-
warn("Reloading Rails application")
80+
$stderr.puts("Reloading Rails application")
8181
send_notification("reload")
8282
rescue IncompleteMessageError
83-
warn("Ruby LSP Rails failed to trigger reload")
83+
$stderr.puts("Ruby LSP Rails failed to trigger reload")
8484
nil
8585
end
8686

8787
sig { void }
8888
def shutdown
89-
warn("Ruby LSP Rails shutting down server")
89+
$stderr.puts("Ruby LSP Rails shutting down server")
9090
send_message("shutdown")
9191
sleep(0.5) # give the server a bit of time to shutdown
9292
[@stdin, @stdout, @stderr].each(&:close)
@@ -130,7 +130,7 @@ def read_response
130130
response = JSON.parse(T.must(raw_response), symbolize_names: true)
131131

132132
if response[:error]
133-
warn("Ruby LSP Rails error: " + response[:error])
133+
$stderr.puts("Ruby LSP Rails error: " + response[:error])
134134
return
135135
end
136136

lib/ruby_lsp/ruby_lsp_rails/support/rails_document_client.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def generate_rails_document_urls(name)
6666
private def build_search_index
6767
return unless RAILTIES_VERSION
6868

69-
warn("Fetching Rails Documents...")
69+
$stderr.puts("Fetching Rails Documents...")
7070

7171
response = Net::HTTP.get_response(URI("#{RAILS_DOC_HOST}/v#{RAILTIES_VERSION}/js/search_index.js"))
7272

@@ -79,13 +79,13 @@ def generate_rails_document_urls(name)
7979
response = Net::HTTP.get_response(URI("#{RAILS_DOC_HOST}/js/search_index.js"))
8080
response.body if response.is_a?(Net::HTTPSuccess)
8181
else
82-
warn("Response failed: #{response.inspect}")
82+
$stderr.puts("Response failed: #{response.inspect}")
8383
nil
8484
end
8585

8686
process_search_index(body) if body
8787
rescue StandardError => e
88-
warn("Exception occurred when fetching Rails document index: #{e.inspect}")
88+
$stderr.puts("Exception occurred when fetching Rails document index: #{e.inspect}")
8989
end
9090

9191
sig { params(js: String).returns(T::Hash[String, T::Array[T::Hash[Symbol, String]]]) }

0 commit comments

Comments
 (0)