From abc073e7ad3b3fb29ece7c2f362febb60386b1b2 Mon Sep 17 00:00:00 2001 From: Lukas Fittl Date: Sat, 27 Jan 2024 09:16:48 -0800 Subject: [PATCH] Apply review feedback --- lib/pg_query/treewalker.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/pg_query/treewalker.rb b/lib/pg_query/treewalker.rb index 83540cc8..4ee9d3c1 100644 --- a/lib/pg_query/treewalker.rb +++ b/lib/pg_query/treewalker.rb @@ -35,15 +35,13 @@ def treewalker!(tree) # rubocop:disable Metrics/CyclomaticComplexity node = field_descriptor.get(parent_node) next if node.nil? yield(node) if node.is_a?(Google::Protobuf::MessageExts) || node.is_a?(Google::Protobuf::RepeatedField) - - nodes << node unless node.nil? + nodes << node end when Google::Protobuf::RepeatedField parent_node.each do |node| next if node.nil? yield(node) if node.is_a?(Google::Protobuf::MessageExts) || node.is_a?(Google::Protobuf::RepeatedField) - - nodes << node unless node.nil? + nodes << node end end @@ -65,16 +63,14 @@ def treewalker_with_location!(tree) # rubocop:disable Metrics/CyclomaticComplexi next if node.nil? location = parent_location + [parent_field.to_sym] yield(parent_node, parent_field.to_sym, node, location) if node.is_a?(Google::Protobuf::MessageExts) || node.is_a?(Google::Protobuf::RepeatedField) - - nodes << [node, location] unless node.nil? + nodes << [node, location] end when Google::Protobuf::RepeatedField parent_node.each_with_index do |node, parent_field| next if node.nil? location = parent_location + [parent_field] yield(parent_node, parent_field, node, location) if node.is_a?(Google::Protobuf::MessageExts) || node.is_a?(Google::Protobuf::RepeatedField) - - nodes << [node, location] unless node.nil? + nodes << [node, location] end end