Skip to content

Commit 916bc75

Browse files
committed
(maint) Update for rubocop errors
This commit updates Editor Services for the new cops introduced in Rubocop 0.68.1.
1 parent 53ad68d commit 916bc75

File tree

5 files changed

+40
-40
lines changed

5 files changed

+40
-40
lines changed

lib/puppet-editor-services/simple_tcp_server.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def fire_event
191191
return false unless event
192192
begin
193193
event[0].call(*event[1])
194-
rescue OpenSSL::SSL::SSLError => _
194+
rescue OpenSSL::SSL::SSLError
195195
log('SSL Bump - SSL Certificate refused?')
196196
# rubocop:disable RescueException
197197
rescue Exception => e
@@ -220,7 +220,7 @@ def io_review
220220
if self.class.services[io]
221221
begin
222222
callback(self, :add_connection, io.accept_nonblock, self.class.services[io])
223-
rescue Errno::EWOULDBLOCK => _ # rubocop:disable Lint/HandleExceptions
223+
rescue Errno::EWOULDBLOCK # rubocop:disable Lint/HandleExceptions
224224
# There's nothing to handle. Swallow the error
225225
rescue StandardError => e
226226
log(e.message)

lib/puppet-languageserver-sidecar/cache/filesystem.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def load(absolute_path, section)
4747
PuppetLanguageServerSidecar.log_message(:debug, "[PuppetLanguageServerSidecar::load] Loading #{absolute_path} from cache")
4848

4949
json_obj['data']
50-
rescue RuntimeError => detail
51-
PuppetLanguageServerSidecar.log_message(:debug, "[PuppetLanguageServerSidecar::load] Error loading #{absolute_path}: #{detail}")
50+
rescue RuntimeError => e
51+
PuppetLanguageServerSidecar.log_message(:debug, "[PuppetLanguageServerSidecar::load] Error loading #{absolute_path}: #{e}")
5252
raise
5353
end
5454

lib/puppet-languageserver-sidecar/puppet_helper.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ def self.retrieve_functions(cache, options = {})
105105
if path_has_child?(options[:root_path], absolute_name) # rubocop:disable Style/IfUnlessModifier Nicer to read like this
106106
funcs.concat(load_function_file(cache, name, absolute_name, autoloader, current_env))
107107
end
108-
rescue StandardError => err
109-
PuppetLanguageServerSidecar.log_message(:error, "[PuppetHelper::load_functions] Error loading function #{file}: #{err} #{err.backtrace}")
108+
rescue StandardError => e
109+
PuppetLanguageServerSidecar.log_message(:error, "[PuppetHelper::load_functions] Error loading function #{file}: #{e} #{e.backtrace}")
110110
end
111111
end
112112

@@ -137,8 +137,8 @@ def self.retrieve_types(cache, options = {})
137137
if path_has_child?(options[:root_path], absolute_name) # rubocop:disable Style/IfUnlessModifier Nicer to read like this
138138
types.concat(load_type_file(cache, name, absolute_name, autoloader, current_env))
139139
end
140-
rescue StandardError => err
141-
PuppetLanguageServerSidecar.log_message(:error, "[PuppetHelper::retrieve_types] Error loading type #{file}: #{err} #{err.backtrace}")
140+
rescue StandardError => e
141+
PuppetLanguageServerSidecar.log_message(:error, "[PuppetHelper::retrieve_types] Error loading type #{file}: #{e} #{e.backtrace}")
142142
end
143143
end
144144

@@ -165,8 +165,8 @@ def self.current_environment
165165
return env unless env.nil?
166166
rescue Puppet::Environments::EnvironmentNotFound
167167
PuppetLanguageServerSidecar.log_message(:warning, "[PuppetHelper::current_environment] Unable to load environment #{Puppet.settings[:environment]}")
168-
rescue StandardError => ex
169-
PuppetLanguageServerSidecar.log_message(:warning, "[PuppetHelper::current_environment] Error loading environment #{Puppet.settings[:environment]}: #{ex}")
168+
rescue StandardError => e
169+
PuppetLanguageServerSidecar.log_message(:warning, "[PuppetHelper::current_environment] Error loading environment #{Puppet.settings[:environment]}: #{e}")
170170
end
171171
Puppet.lookup(:current_environment)
172172
end
@@ -194,7 +194,7 @@ def self.load_classes_from_manifest(cache, manifest_file)
194194
result = nil
195195
begin
196196
result = parser.parse_string(file_content, '')
197-
rescue Puppet::ParseErrorWithIssue => _exception
197+
rescue Puppet::ParseErrorWithIssue
198198
# Any parsing errors means we can't inspect the document
199199
return class_info
200200
end
@@ -309,12 +309,12 @@ def self.load_type_file(cache, name, absolute_name, autoloader, env)
309309
# will throw instead of not yielding.
310310
begin
311311
Puppet::Type.eachtype { |item| loaded_types << item.name }
312-
rescue NoMethodError => detail
312+
rescue NoMethodError => e
313313
# Detect PUP-8301
314-
if detail.respond_to?(:receiver)
315-
raise unless detail.name == :each && detail.receiver.nil?
314+
if e.respond_to?(:receiver)
315+
raise unless e.name == :each && e.receiver.nil?
316316
else
317-
raise unless detail.name == :each && detail.message =~ /nil:NilClass/
317+
raise unless e.name == :each && e.message =~ /nil:NilClass/
318318
end
319319
end
320320

@@ -339,12 +339,12 @@ def self.load_type_file(cache, name, absolute_name, autoloader, env)
339339
obj.calling_source = absolute_name
340340
types << obj
341341
end
342-
rescue NoMethodError => detail
342+
rescue NoMethodError => e
343343
# Detect PUP-8301
344-
if detail.respond_to?(:receiver)
345-
raise unless detail.name == :each && detail.receiver.nil?
344+
if e.respond_to?(:receiver)
345+
raise unless e.name == :each && e.receiver.nil?
346346
else
347-
raise unless detail.name == :each && detail.message =~ /nil:NilClass/
347+
raise unless e.name == :each && e.message =~ /nil:NilClass/
348348
end
349349
end
350350
PuppetLanguageServerSidecar.log_message(:warn, "[PuppetHelper::load_type_file] type #{absolute_name} did not load any types") if types.empty?

lib/puppet-languageserver/message_router.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def receive_request(request)
8989
'fixesApplied' => changes,
9090
'newContent' => changes > 0 || formatted_request.alwaysReturnContent ? new_content : nil
9191
))
92-
rescue StandardError => exception
93-
PuppetLanguageServer.log_message(:error, "(puppet/fixDiagnosticErrors) #{exception}")
92+
rescue StandardError => e
93+
PuppetLanguageServer.log_message(:error, "(puppet/fixDiagnosticErrors) #{e}")
9494
unless formatted_request.nil?
9595
request.reply_result(LSP::PuppetFixDiagnosticErrorsResponse.new(
9696
'documentUri' => formatted_request.documentUri,
@@ -112,8 +112,8 @@ def receive_request(request)
112112
else
113113
raise "Unable to provide completion on #{file_uri}"
114114
end
115-
rescue StandardError => exception
116-
PuppetLanguageServer.log_message(:error, "(textDocument/completion) #{exception}")
115+
rescue StandardError => e
116+
PuppetLanguageServer.log_message(:error, "(textDocument/completion) #{e}")
117117
request.reply_result(LSP::CompletionList.new('isIncomplete' => false, 'items' => []))
118118
end
119119

@@ -122,8 +122,8 @@ def receive_request(request)
122122
request.reply_result(PuppetLanguageServer::Manifest::CompletionProvider.resolve(
123123
LSP::CompletionItem.new(request.params)
124124
))
125-
rescue StandardError => exception
126-
PuppetLanguageServer.log_message(:error, "(completionItem/resolve) #{exception}")
125+
rescue StandardError => e
126+
PuppetLanguageServer.log_message(:error, "(completionItem/resolve) #{e}")
127127
# Spit back the same params if an error happens
128128
request.reply_result(request.params)
129129
end
@@ -140,8 +140,8 @@ def receive_request(request)
140140
else
141141
raise "Unable to provide hover on #{file_uri}"
142142
end
143-
rescue StandardError => exception
144-
PuppetLanguageServer.log_message(:error, "(textDocument/hover) #{exception}")
143+
rescue StandardError => e
144+
PuppetLanguageServer.log_message(:error, "(textDocument/hover) #{e}")
145145
request.reply_result(LSP::Hover.new)
146146
end
147147

@@ -157,8 +157,8 @@ def receive_request(request)
157157
else
158158
raise "Unable to provide definition on #{file_uri}"
159159
end
160-
rescue StandardError => exception
161-
PuppetLanguageServer.log_message(:error, "(textDocument/definition) #{exception}")
160+
rescue StandardError => e
161+
PuppetLanguageServer.log_message(:error, "(textDocument/definition) #{e}")
162162
request.reply_result(nil)
163163
end
164164

@@ -172,8 +172,8 @@ def receive_request(request)
172172
else
173173
raise "Unable to provide definition on #{file_uri}"
174174
end
175-
rescue StandardError => exception
176-
PuppetLanguageServer.log_message(:error, "(textDocument/documentSymbol) #{exception}")
175+
rescue StandardError => e
176+
PuppetLanguageServer.log_message(:error, "(textDocument/documentSymbol) #{e}")
177177
request.reply_result(nil)
178178
end
179179

@@ -182,16 +182,16 @@ def receive_request(request)
182182
result = []
183183
result.concat(PuppetLanguageServer::Manifest::DocumentSymbolProvider.workspace_symbols(request.params['query']))
184184
request.reply_result(result)
185-
rescue StandardError => exception
186-
PuppetLanguageServer.log_message(:error, "(workspace/symbol) #{exception}")
185+
rescue StandardError => e
186+
PuppetLanguageServer.log_message(:error, "(workspace/symbol) #{e}")
187187
request.reply_result([])
188188
end
189189

190190
else
191191
PuppetLanguageServer.log_message(:error, "Unknown RPC method #{request.rpc_method}")
192192
end
193-
rescue StandardError => err
194-
PuppetLanguageServer::CrashDump.write_crash_file(err, nil, 'request' => request.rpc_method, 'params' => request.params)
193+
rescue StandardError => e
194+
PuppetLanguageServer::CrashDump.write_crash_file(e, nil, 'request' => request.rpc_method, 'params' => request.params)
195195
raise
196196
end
197197

@@ -240,8 +240,8 @@ def receive_notification(method, params)
240240
else
241241
PuppetLanguageServer.log_message(:error, "Unknown RPC notification #{method}")
242242
end
243-
rescue StandardError => err
244-
PuppetLanguageServer::CrashDump.write_crash_file(err, nil, 'notification' => method, 'params' => params)
243+
rescue StandardError => e
244+
PuppetLanguageServer::CrashDump.write_crash_file(e, nil, 'notification' => method, 'params' => params)
245245
raise
246246
end
247247
end

lib/puppet_languageserver_sidecar.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ def self.execute(options)
240240
begin
241241
manifest = File.open(options[:action_parameters]['source'], 'r:UTF-8') { |f| f.read }
242242
PuppetLanguageServerSidecar::PuppetParserHelper.compile_node_graph(manifest)
243-
rescue StandardError => ex
244-
log_message(:error, "Unable to compile the manifest. #{ex}")
245-
result.set_error("Unable to compile the manifest. #{ex}")
243+
rescue StandardError => e
244+
log_message(:error, "Unable to compile the manifest. #{e}")
245+
result.set_error("Unable to compile the manifest. #{e}")
246246
end
247247

248248
when 'resource_list'

0 commit comments

Comments
 (0)