Merge pull request #9470 from SeekingMeaning/on-os-rubocop

on_macos/on_linux block: fix rubocop for special cases
This commit is contained in:
Seeker 2020-12-09 21:24:09 -08:00 committed by GitHub
commit b3236ced45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -137,11 +137,13 @@ module RuboCop
def check_on_os_block_content(component_precedence_list, on_os_block) def check_on_os_block_content(component_precedence_list, on_os_block)
_, offensive_node = check_order(component_precedence_list, on_os_block.body) _, offensive_node = check_order(component_precedence_list, on_os_block.body)
component_problem(*offensive_node) if offensive_node 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) valid_node = depends_on_node?(child)
# Check for RuboCop::AST::SendNode instances only, as we are checking the # Check for RuboCop::AST::SendNode and RuboCop::AST::BlockNode instances
# method_name for patches and resources. # only, as we are checking the method_name for `patch`, `resource`, etc.
next unless child.instance_of? RuboCop::AST::SendNode 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 == "patch"
valid_node ||= child.method_name.to_s == "resource" valid_node ||= child.method_name.to_s == "resource"