aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/rubocops/extend/formula_cop.rb
diff options
context:
space:
mode:
authorMike McQuaid2017-06-09 09:46:05 +0300
committerGitHub2017-06-09 09:46:05 +0300
commite83e394a731f3317dc09a5eb1210ff6996e40ed2 (patch)
tree73a9cc10ded84946bad2773b9fc848ec607b3315 /Library/Homebrew/rubocops/extend/formula_cop.rb
parent0e2b043c125538dab0cee416bff908034ad37e84 (diff)
parentd09d5ecc559c4971fae77769cb1a203bb20c7a97 (diff)
downloadbrew-e83e394a731f3317dc09a5eb1210ff6996e40ed2.tar.bz2
Merge pull request #2755 from GauthamGoli/audit_checksum_rubocop
audit: Port audit_checksum method to rubocop and add tests
Diffstat (limited to 'Library/Homebrew/rubocops/extend/formula_cop.rb')
-rw-r--r--Library/Homebrew/rubocops/extend/formula_cop.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/Library/Homebrew/rubocops/extend/formula_cop.rb b/Library/Homebrew/rubocops/extend/formula_cop.rb
index 75a3e72d5..b6fa45d3f 100644
--- a/Library/Homebrew/rubocops/extend/formula_cop.rb
+++ b/Library/Homebrew/rubocops/extend/formula_cop.rb
@@ -167,12 +167,18 @@ module RuboCop
nil
end
- # Returns an array of block nodes named block_name inside node
+ # Returns an array of block nodes of depth first order named block_name below node
def find_blocks(node, block_name)
return if node.nil?
node.each_child_node(:block).select { |block_node| block_name == block_node.method_name }
end
+ # Returns an array of block nodes of any depth below node in AST
+ def find_all_blocks(node, block_name)
+ return if node.nil?
+ node.each_descendant(:block).select { |block_node| block_name == block_node.method_name }
+ end
+
# Returns a method definition node with method_name
def find_method_def(node, method_name)
return if node.nil?
@@ -250,8 +256,7 @@ module RuboCop
# Returns the array of arguments of the method_node
def parameters(method_node)
- return unless method_node.send_type?
- method_node.method_args
+ method_node.method_args if method_node.send_type? || method_node.block_type?
end
# Returns true if the given parameters are present in method call