Skip to content

Commit 3d9983b

Browse files
committed
(maint) Update for Rubocop 0.77.0
This commit updates the project for Rubocop 0.77.0 Due to there being so many differences in rubocop for Ruby < 2.3.0, this commit also stops bundling rubocop for old Ruby versions.
1 parent 59fc76d commit 3d9983b

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

.rubocop.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Style/SymbolProc:
7878
Style/HashSyntax:
7979
Enabled: false
8080

81-
Layout/AlignHash:
81+
Layout/HashAlignment:
8282
EnforcedHashRocketStyle: table
8383

8484
Naming/RescuedExceptionsVariableName:
@@ -90,4 +90,8 @@ Style/NumericPredicate:
9090

9191
# This is not valid on Ruby 2.1
9292
Style/SafeNavigation:
93-
Enabled: false
93+
Enabled: false
94+
95+
# This is not valid on Ruby 2.1
96+
Layout/HeredocIndentation:
97+
Enabled: false

Gemfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ group :development do
1212
gem 'rake', '>= 10.4', :require => false
1313
gem 'rspec', '>= 3.2', :require => false
1414

15-
if RUBY_VERSION =~ /^2\.1\./
16-
gem "rubocop", "<= 0.57.2", :require => false, :platforms => [:ruby, :x64_mingw]
17-
else
18-
gem "rubocop", ">= 0.60.0", :require => false, :platforms => [:ruby, :x64_mingw]
15+
if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.3.0')
16+
gem "rubocop", ">= 0.77.0", :require => false, :platforms => [:ruby, :x64_mingw]
1917
end
2018

2119
if ENV['PUPPET_GEM_VERSION']

lib/puppet-debugserver/debug_session/hook_handlers.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,20 @@ def on_hook_before_pops_evaluate(args)
144144
# Stepping-in is basically break on everything
145145
# Re-raise the hook as a step breakpoint
146146
@debug_session.execute_hook(:hook_step_breakpoint, [ast_classname, ''] + args)
147-
return
148147
when :next
149148
# Next will break on anything at this Pop depth or shallower than this Pop depth. Re-raise the hook as a step breakpoint
150149
depth = @debug_session.flow_control.run_mode.options[:pops_depth_level] || -1
151-
if @debug_session.puppet_session_state.actual.pops_depth_level <= depth
150+
if @debug_session.puppet_session_state.actual.pops_depth_level <= depth # rubocop:disable Style/IfUnlessModifier
152151
@debug_session.execute_hook(:hook_step_breakpoint, [ast_classname, ''] + args)
153-
return
154152
end
155153
when :stepout
156154
# Stepping-Out will break on anything shallower than this Pop depth. Re-raise the hook as a step breakpoint
157155
depth = @debug_session.flow_control.run_mode.options[:pops_depth_level] || -1
158-
if @debug_session.puppet_session_state.actual.pops_depth_level < depth
156+
if @debug_session.puppet_session_state.actual.pops_depth_level < depth # rubocop:disable Style/IfUnlessModifier
159157
@debug_session.execute_hook(:hook_step_breakpoint, [ast_classname, ''] + args)
160-
return
161158
end
162159
end
160+
nil
163161
end
164162

165163
# Fires when a source/line breakpoint is hit

lib/puppet-languageserver-sidecar/puppet_modulepath_monkey_patches.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def create_workspace_module_object(path)
7373
# https://github.com/puppetlabs/puppet/commit/935c0311dbaf1df03937822525c36b26de5390ef
7474
# We need to switch the creation based on whether the modules_strict_semver? method is available
7575
return Puppet::Module.new(module_name, path, self, modules_strict_semver?) if respond_to?('modules_strict_semver?')
76-
return Puppet::Module.new(module_name, path, self)
76+
Puppet::Module.new(module_name, path, self)
7777
rescue StandardError
78-
return nil
78+
nil
7979
end
8080
end
8181

lib/puppet-languageserver/crash_dump.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def self.write_crash_file(err, filename = nil, additional = {})
4343

4444
crash_file = filename.nil? ? default_crash_file : filename
4545
File.open(crash_file, 'wb') { |file| file.write(crashtext) }
46-
rescue # rubocop:disable Style/RescueStandardError, Lint/HandleExceptions
46+
rescue # rubocop:disable Style/RescueStandardError, Lint/SuppressedException
4747
# Swallow all errors. Errors in the error handler should not
4848
# terminate the application
4949
end

lib/puppet-languageserver/manifest/validation_provider.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ def self.validate(content, options = {})
8080
'message' => problem[:message])
8181
end
8282
end
83-
# rubocop:disable Lint/HandleExceptions
83+
# rubocop:disable Lint/SuppressedException
8484
rescue StandardError
8585
# If anything catastrophic happens we resort to puppet parsing anyway
8686
end
87-
# rubocop:enable Lint/HandleExceptions
87+
# rubocop:enable Lint/SuppressedException
8888

8989
# TODO: Should I wrap this thing in a big rescue block?
9090
Puppet[:code] = content

lib/puppet-languageserver/message_handler.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ def request_puppet_compilenodegraph(_, json_rpc_message)
6464

6565
begin
6666
node_graph = PuppetLanguageServer::PuppetHelper.get_node_graph(content, documents.store_root_path)
67-
return LSP::CompileNodeGraphResponse.new('dotContent' => node_graph.dot_content,
68-
'error' => node_graph.error_content)
67+
LSP::CompileNodeGraphResponse.new('dotContent' => node_graph.dot_content,
68+
'error' => node_graph.error_content)
6969
rescue StandardError => e
7070
PuppetLanguageServer.log_message(:error, "(puppet/compileNodeGraph) Error generating node graph. #{e}")
71-
return LSP::CompileNodeGraphResponse.new('error' => 'An internal error occured while generating the the node graph. Please see the debug log files for more information.')
71+
LSP::CompileNodeGraphResponse.new('error' => 'An internal error occured while generating the the node graph. Please see the debug log files for more information.')
7272
end
7373
end
7474

@@ -92,7 +92,7 @@ def request_puppet_fixdiagnosticerrors(_, json_rpc_message)
9292
rescue StandardError => e
9393
PuppetLanguageServer.log_message(:error, "(puppet/fixDiagnosticErrors) #{e}")
9494
unless formatted_request.nil?
95-
return LSP::PuppetFixDiagnosticErrorsResponse.new(
95+
LSP::PuppetFixDiagnosticErrorsResponse.new(
9696
'documentUri' => formatted_request.documentUri,
9797
'fixesApplied' => 0,
9898
'newContent' => formatted_request.alwaysReturnContent ? content : nil # rubocop:disable Metrics/BlockNesting
@@ -109,7 +109,7 @@ def request_textdocument_completion(_, json_rpc_message)
109109

110110
case documents.document_type(file_uri)
111111
when :manifest
112-
return PuppetLanguageServer::Manifest::CompletionProvider.complete(content, line_num, char_num, :context => context, :tasks_mode => PuppetLanguageServer::DocumentStore.plan_file?(file_uri))
112+
PuppetLanguageServer::Manifest::CompletionProvider.complete(content, line_num, char_num, :context => context, :tasks_mode => PuppetLanguageServer::DocumentStore.plan_file?(file_uri))
113113
else
114114
raise "Unable to provide completion on #{file_uri}"
115115
end
@@ -133,7 +133,7 @@ def request_textdocument_hover(_, json_rpc_message)
133133
content = documents.document(file_uri)
134134
case documents.document_type(file_uri)
135135
when :manifest
136-
return PuppetLanguageServer::Manifest::HoverProvider.resolve(content, line_num, char_num, :tasks_mode => PuppetLanguageServer::DocumentStore.plan_file?(file_uri))
136+
PuppetLanguageServer::Manifest::HoverProvider.resolve(content, line_num, char_num, :tasks_mode => PuppetLanguageServer::DocumentStore.plan_file?(file_uri))
137137
else
138138
raise "Unable to provide hover on #{file_uri}"
139139
end
@@ -150,7 +150,7 @@ def request_textdocument_definition(_, json_rpc_message)
150150

151151
case documents.document_type(file_uri)
152152
when :manifest
153-
return PuppetLanguageServer::Manifest::DefinitionProvider.find_definition(content, line_num, char_num, :tasks_mode => PuppetLanguageServer::DocumentStore.plan_file?(file_uri))
153+
PuppetLanguageServer::Manifest::DefinitionProvider.find_definition(content, line_num, char_num, :tasks_mode => PuppetLanguageServer::DocumentStore.plan_file?(file_uri))
154154
else
155155
raise "Unable to provide definition on #{file_uri}"
156156
end
@@ -165,7 +165,7 @@ def request_textdocument_documentsymbol(_, json_rpc_message)
165165

166166
case documents.document_type(file_uri)
167167
when :manifest
168-
return PuppetLanguageServer::Manifest::DocumentSymbolProvider.extract_document_symbols(content, :tasks_mode => PuppetLanguageServer::DocumentStore.plan_file?(file_uri))
168+
PuppetLanguageServer::Manifest::DocumentSymbolProvider.extract_document_symbols(content, :tasks_mode => PuppetLanguageServer::DocumentStore.plan_file?(file_uri))
169169
else
170170
raise "Unable to provide definition on #{file_uri}"
171171
end
@@ -183,7 +183,7 @@ def request_textdocument_ontypeformatting(_, json_rpc_message)
183183

184184
case documents.document_type(file_uri)
185185
when :manifest
186-
return PuppetLanguageServer::Manifest::FormatOnTypeProvider.instance.format(
186+
PuppetLanguageServer::Manifest::FormatOnTypeProvider.instance.format(
187187
content,
188188
line_num,
189189
char_num,
@@ -206,7 +206,7 @@ def request_textdocument_signaturehelp(_, json_rpc_message)
206206

207207
case documents.document_type(file_uri)
208208
when :manifest
209-
return PuppetLanguageServer::Manifest::SignatureProvider.signature_help(
209+
PuppetLanguageServer::Manifest::SignatureProvider.signature_help(
210210
content,
211211
line_num,
212212
char_num,

lib/puppet_editor_services/server/stdio.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def read_from_pipe(pipe, timeout = 0.1, &_block)
7070
rescue EOFError
7171
log('Reading from pipe has reached End of File. Exiting STDIO server')
7272
stop
73-
rescue # rubocop:disable Style/RescueStandardError, Lint/HandleExceptions
73+
rescue # rubocop:disable Style/RescueStandardError, Lint/SuppressedException
7474
# Any errors here should be swallowed because the pipe could be in any state
7575
end
7676
# since readpartial may return a nil at EOF, skip returning that value

lib/puppet_editor_services/server/tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def io_review
200200
if self.class.services[io]
201201
begin
202202
callback(self, :add_connection, io.accept_nonblock, self.class.services[io])
203-
rescue Errno::EWOULDBLOCK # rubocop:disable Lint/HandleExceptions
203+
rescue Errno::EWOULDBLOCK # rubocop:disable Lint/SuppressedException
204204
# There's nothing to handle. Swallow the error
205205
rescue StandardError => e
206206
log(e.message)

0 commit comments

Comments
 (0)