diff --git a/lib/puppet-debugserver/puppet_debug_session.rb b/lib/puppet-debugserver/puppet_debug_session.rb index 9e59600c..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 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/server/tcp.rb b/lib/puppet_editor_services/server/tcp.rb index 7df22a02..a24f3324 100644 --- a/lib/puppet_editor_services/server/tcp.rb +++ b/lib/puppet_editor_services/server/tcp.rb @@ -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