From 5a643ff0db4fe6659bee1375e20acad265366006 Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 8 Dec 2020 14:33:37 -0800 Subject: [PATCH] on_macos/on_linux block: fix rubocop for special cases --- Library/Homebrew/rubocops/components_order.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/rubocops/components_order.rb b/Library/Homebrew/rubocops/components_order.rb index 434e52579b..e23a2dfa2b 100644 --- a/Library/Homebrew/rubocops/components_order.rb +++ b/Library/Homebrew/rubocops/components_order.rb @@ -137,11 +137,13 @@ module RuboCop def check_on_os_block_content(component_precedence_list, on_os_block) _, offensive_node = check_order(component_precedence_list, on_os_block.body) component_problem(*offensive_node) if offensive_node - on_os_block.body.child_nodes.each do |child| + child_nodes = on_os_block.body.begin_type? ? on_os_block.body.child_nodes : [on_os_block.body] + child_nodes.each do |child| valid_node = depends_on_node?(child) - # Check for RuboCop::AST::SendNode instances only, as we are checking the - # method_name for patches and resources. - next unless child.instance_of? RuboCop::AST::SendNode + # Check for RuboCop::AST::SendNode and RuboCop::AST::BlockNode instances + # only, as we are checking the method_name for `patch`, `resource`, etc. + method_type = child.send_type? || child.block_type? + next unless method_type valid_node ||= child.method_name.to_s == "patch" valid_node ||= child.method_name.to_s == "resource"