From f10ff2bad8bacc74763fd1363a32ccaab666bd67 Mon Sep 17 00:00:00 2001 From: Gavin Didrichsen Date: Thu, 13 Jun 2024 13:28:07 +0100 Subject: [PATCH 1/3] Revert "(maint) Exclude breaking rubocop versions" --- Gemfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Gemfile b/Gemfile index 99688344..ebc115ac 100644 --- a/Gemfile +++ b/Gemfile @@ -17,8 +17,6 @@ group :development do gem "rubocop", '~> 1.50.0', :require => false gem "rubocop-performance", '~> 1.16', :require => false gem "rubocop-rspec", '~> 2.19', :require => false - gem 'rubocop-factory_bot', '!= 2.26.0', require: false - gem 'rubocop-rspec_rails', '!= 2.29.0', require: false gem 'simplecov', :require => false gem 'simplecov-console', :require => false From 2fa49d5d52033d2083f2eda1e4727cfaa11d303c Mon Sep 17 00:00:00 2001 From: Gavin Didrichsen Date: Thu, 13 Jun 2024 13:29:15 +0100 Subject: [PATCH 2/3] Update rubocop gems --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index ebc115ac..08f421fa 100644 --- a/Gemfile +++ b/Gemfile @@ -14,9 +14,9 @@ group :development do gem 'puppet-lint', '~> 4.0', :require => false gem 'puppetfile-resolver', '~> 0.6.2', :require => false gem 'yard', '~> 0.9.28', :require => false - gem "rubocop", '~> 1.50.0', :require => false + gem "rubocop", '~> 1.64.0', :require => false gem "rubocop-performance", '~> 1.16', :require => false - gem "rubocop-rspec", '~> 2.19', :require => false + gem "rubocop-rspec", '~> 3.0', :require => false gem 'simplecov', :require => false gem 'simplecov-console', :require => false From b65b51c1de4a88f740a6f089fdd03a8e99f305de Mon Sep 17 00:00:00 2001 From: Gavin Didrichsen Date: Thu, 20 Jun 2024 12:14:06 +0100 Subject: [PATCH 3/3] Fix rubocop warnings Signed-off-by: Gavin Didrichsen --- .../debug_session/hook_handlers.rb | 2 +- lib/puppet-debugserver/puppet_debug_session.rb | 9 +++------ .../global_queues/sidecar_queue.rb | 2 +- .../global_queues/validation_queue.rb | 2 +- lib/puppet-languageserver/message_handler.rb | 2 +- .../session_state/object_cache.rb | 6 +++--- lib/puppet-languageserver/sidecar_protocol.rb | 13 ++++++------- .../protocol/debug_adapter.rb | 2 +- .../protocol/debug_adapter_messages.rb | 6 +++--- lib/puppet_editor_services/protocol/json_rpc.rb | 2 +- .../protocol/json_rpc_messages.rb | 6 +++--- lib/puppet_editor_services/server/tcp.rb | 4 ++-- 12 files changed, 26 insertions(+), 30 deletions(-) diff --git a/lib/puppet-debugserver/debug_session/hook_handlers.rb b/lib/puppet-debugserver/debug_session/hook_handlers.rb index 61c51d1c..7bd37ad6 100644 --- a/lib/puppet-debugserver/debug_session/hook_handlers.rb +++ b/lib/puppet-debugserver/debug_session/hook_handlers.rb @@ -209,7 +209,7 @@ def on_hook_log_message(args) msg = args[0] str = msg.respond_to?(:multiline) ? msg.multiline : msg.to_s - str = msg.source == 'Puppet' ? str : "#{msg.source}: #{str}" + str = "#{msg.source}: #{str}" unless msg.source == 'Puppet' level = msg.level.to_s.capitalize diff --git a/lib/puppet-debugserver/puppet_debug_session.rb b/lib/puppet-debugserver/puppet_debug_session.rb index e9655b64..5e9b7341 100644 --- a/lib/puppet-debugserver/puppet_debug_session.rb +++ b/lib/puppet-debugserver/puppet_debug_session.rb @@ -431,12 +431,9 @@ def line_for_offset(obj, offset) # @return [Array] Array of DSP::Variable # @private def variable_list_from_hash(obj_hash = {}) - result = [] - obj_hash.sort.each do |key, value| - result << variable_from_ruby_object(key, value) + obj_hash.sort.map do |key, value| + variable_from_ruby_object(key, value) end - - result end # Converts an array of ruby objects into an array of DSP::Variable objects @@ -515,7 +512,7 @@ class LogMessageAggregator # @param hook_manager [PuppetDebugServer::Hooks] The hook manager to use def initialize(hook_manager) @hook_manager = hook_manager - @hook_id = "aggregator#{object_id}".intern + @hook_id = :"aggregator#{object_id}" @messages = [] @started = false end diff --git a/lib/puppet-languageserver/global_queues/sidecar_queue.rb b/lib/puppet-languageserver/global_queues/sidecar_queue.rb index 13241a3b..fa0ca129 100644 --- a/lib/puppet-languageserver/global_queues/sidecar_queue.rb +++ b/lib/puppet-languageserver/global_queues/sidecar_queue.rb @@ -31,7 +31,7 @@ def job_class end def execute_job(job_object) - super(job_object) + super connection = connection_from_connection_id(job_object.connection_id) raise "Connection is not available for connection id #{job_object.connection_id}" if connection.nil? diff --git a/lib/puppet-languageserver/global_queues/validation_queue.rb b/lib/puppet-languageserver/global_queues/validation_queue.rb index ad952c94..179b8ff9 100644 --- a/lib/puppet-languageserver/global_queues/validation_queue.rb +++ b/lib/puppet-languageserver/global_queues/validation_queue.rb @@ -31,7 +31,7 @@ def job_class end def execute_job(job_object) - super(job_object) + super session_state = session_state_from_connection_id(job_object.connection_id) document_store = session_state.nil? ? nil : session_state.documents raise "Document store is not available for connection id #{job_object.connection_id}" unless document_store diff --git a/lib/puppet-languageserver/message_handler.rb b/lib/puppet-languageserver/message_handler.rb index 6265630d..07b8a215 100644 --- a/lib/puppet-languageserver/message_handler.rb +++ b/lib/puppet-languageserver/message_handler.rb @@ -388,7 +388,7 @@ def response_workspace_configuration(_, json_rpc_message, original_request) end def unhandled_exception(error, options) - super(error, options) + super PuppetLanguageServer::CrashDump.write_crash_file(error, session_state, nil, options) end diff --git a/lib/puppet-languageserver/session_state/object_cache.rb b/lib/puppet-languageserver/session_state/object_cache.rb index e013f3f8..b697799a 100644 --- a/lib/puppet-languageserver/session_state/object_cache.rb +++ b/lib/puppet-languageserver/session_state/object_cache.rb @@ -128,7 +128,7 @@ def objects_by_section(section, &_block) return if section.nil? @cache_lock.synchronize do - @inmemory_cache.each do |_, sections| + @inmemory_cache.each_value do |sections| next if sections.nil? || sections[section].nil? || sections[section].empty? sections[section].each { |i| yield i.key, i } @@ -138,10 +138,10 @@ def objects_by_section(section, &_block) def all_objects(&_block) @cache_lock.synchronize do - @inmemory_cache.each do |_origin, sections| + @inmemory_cache.each_value do |sections| next if sections.nil? - sections.each do |_section_name, list| + sections.each_value do |list| list.each { |i| yield i.key, i } end end diff --git a/lib/puppet-languageserver/sidecar_protocol.rb b/lib/puppet-languageserver/sidecar_protocol.rb index adff1d48..7f869c12 100644 --- a/lib/puppet-languageserver/sidecar_protocol.rb +++ b/lib/puppet-languageserver/sidecar_protocol.rb @@ -67,13 +67,12 @@ def eql?(other) end def hash - props = [] - self.class - .instance_methods(false) - .reject { |name| name.to_s.end_with?('=', '!') } - .reject { |name| %i[to_h to_json].include?(name) } - .each do |method_name| - props << send(method_name).hash + props = self.class + .instance_methods(false) + .reject { |name| name.to_s.end_with?('=', '!') } + .reject { |name| %i[to_h to_json].include?(name) } + .map do |method_name| + send(method_name).hash end props.hash end diff --git a/lib/puppet_editor_services/protocol/debug_adapter.rb b/lib/puppet_editor_services/protocol/debug_adapter.rb index 586e0d50..5f3eb896 100644 --- a/lib/puppet_editor_services/protocol/debug_adapter.rb +++ b/lib/puppet_editor_services/protocol/debug_adapter.rb @@ -11,7 +11,7 @@ class DebugAdapter < ::PuppetEditorServices::Protocol::Base KEY_TYPE = 'type' def initialize(connection) - super(connection) + super @state = :data @buffer = [] diff --git a/lib/puppet_editor_services/protocol/debug_adapter_messages.rb b/lib/puppet_editor_services/protocol/debug_adapter_messages.rb index 39b72693..93dec272 100644 --- a/lib/puppet_editor_services/protocol/debug_adapter_messages.rb +++ b/lib/puppet_editor_services/protocol/debug_adapter_messages.rb @@ -54,7 +54,7 @@ def initialize(initial_hash = nil) def from_h!(value) value = {} if value.nil? - super(value) + super self.command = value['command'] self.arguments = value['arguments'] self @@ -84,7 +84,7 @@ def initialize(initial_hash = nil) def from_h!(value) value = {} if value.nil? - super(value) + super self.event = value['event'] self.body = value['body'] self @@ -121,7 +121,7 @@ def initialize(initial_hash = nil) def from_h!(value) value = {} if value.nil? - super(value) + super self.request_seq = value['request_seq'] self.success = value['success'] self.command = value['command'] diff --git a/lib/puppet_editor_services/protocol/json_rpc.rb b/lib/puppet_editor_services/protocol/json_rpc.rb index 0d2fbab2..14a93ad1 100644 --- a/lib/puppet_editor_services/protocol/json_rpc.rb +++ b/lib/puppet_editor_services/protocol/json_rpc.rb @@ -45,7 +45,7 @@ class JsonRPC < ::PuppetEditorServices::Protocol::Base KEY_MESSAGE = 'message' def initialize(connection) - super(connection) + super @state = :data @buffer = [] diff --git a/lib/puppet_editor_services/protocol/json_rpc_messages.rb b/lib/puppet_editor_services/protocol/json_rpc_messages.rb index 97adcb1c..c9026ae8 100644 --- a/lib/puppet_editor_services/protocol/json_rpc_messages.rb +++ b/lib/puppet_editor_services/protocol/json_rpc_messages.rb @@ -58,7 +58,7 @@ def initialize(initial_hash = nil) def from_h!(value) value = {} if value.nil? - super(value) + super self.id = value['id'] self.rpc_method = value['method'] self.params = value['params'] @@ -94,7 +94,7 @@ def initialize(initial_hash = nil) def from_h!(value) value = {} if value.nil? - super(value) + super self.rpc_method = value['method'] self.params = value['params'] self @@ -136,7 +136,7 @@ def initialize(initial_hash = nil) def from_h!(value) value = {} if value.nil? - super(value) + super self.id = value['id'] self.result = value['result'] self.error = value['error'] diff --git a/lib/puppet_editor_services/server/tcp.rb b/lib/puppet_editor_services/server/tcp.rb index 4922788a..a24f3324 100644 --- a/lib/puppet_editor_services/server/tcp.rb +++ b/lib/puppet_editor_services/server/tcp.rb @@ -140,7 +140,7 @@ def events? # @api private def push_event(handler, *args, &block) if block - self.class.e_locker.synchronize { self.class.events << [(proc { |a| push_event block, handler.call(*a) }), args] } + self.class.e_locker.synchronize { self.class.events << [proc { |a| push_event block, handler.call(*a) }, args] } else self.class.e_locker.synchronize { self.class.events << [handler, args] } end @@ -301,7 +301,7 @@ def add_connection(io, service_object) # @api public def connection(connection_id) self.class.c_locker.synchronize do - self.class.io_connection_dic.each do |_, v| + self.class.io_connection_dic.each_value do |v| return v[:handler] unless v[:handler].nil? || v[:handler].id != connection_id end end