From b5a0cfd86180790b0071becc744a2da2fda3703e Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Mon, 19 Jun 2017 00:36:18 -0400 Subject: [PATCH] rubocops: use consistent (_)body_node parameter name --- Library/Homebrew/rubocops/bottle_block_cop.rb | 4 ++-- Library/Homebrew/rubocops/components_order_cop.rb | 8 ++++---- .../Homebrew/rubocops/components_redundancy_cop.rb | 14 +++++++------- Library/Homebrew/rubocops/formula_desc_cop.rb | 8 ++++---- Library/Homebrew/rubocops/homepage_cop.rb | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Library/Homebrew/rubocops/bottle_block_cop.rb b/Library/Homebrew/rubocops/bottle_block_cop.rb index f0c7d59bb1..77759e427a 100644 --- a/Library/Homebrew/rubocops/bottle_block_cop.rb +++ b/Library/Homebrew/rubocops/bottle_block_cop.rb @@ -10,8 +10,8 @@ module RuboCop class BottleBlock < FormulaCop MSG = "Use rebuild instead of revision in bottle block".freeze - def audit_formula(_node, _class_node, _parent_class_node, formula_class_body_node) - bottle = find_block(formula_class_body_node, :bottle) + def audit_formula(_node, _class_node, _parent_class_node, body_node) + bottle = find_block(body_node, :bottle) return if bottle.nil? || block_size(bottle).zero? problem "Use rebuild instead of revision in bottle block" if method_called_in_block?(bottle, :revision) end diff --git a/Library/Homebrew/rubocops/components_order_cop.rb b/Library/Homebrew/rubocops/components_order_cop.rb index a63490395b..f1179d9a4d 100644 --- a/Library/Homebrew/rubocops/components_order_cop.rb +++ b/Library/Homebrew/rubocops/components_order_cop.rb @@ -8,7 +8,7 @@ module RuboCop # - component_precedence_list has component hierarchy in a nested list # where each sub array contains components' details which are at same precedence level class ComponentsOrder < FormulaCop - def audit_formula(_node, _class_node, _parent_class_node, formula_class_body_node) + def audit_formula(_node, _class_node, _parent_class_node, body_node) component_precedence_list = [ [{ name: :include, type: :method_call }], [{ name: :desc, type: :method_call }], @@ -41,11 +41,11 @@ module RuboCop components.each do |component| case component[:type] when :method_call - relevant_components += find_method_calls_by_name(formula_class_body_node, component[:name]).to_a + relevant_components += find_method_calls_by_name(body_node, component[:name]).to_a when :block_call - relevant_components += find_blocks(formula_class_body_node, component[:name]).to_a + relevant_components += find_blocks(body_node, component[:name]).to_a when :method_definition - relevant_components << find_method_def(formula_class_body_node, component[:name]) + relevant_components << find_method_def(body_node, component[:name]) end end relevant_components.delete_if(&:nil?) diff --git a/Library/Homebrew/rubocops/components_redundancy_cop.rb b/Library/Homebrew/rubocops/components_redundancy_cop.rb index 52dba4718f..7495b986b7 100644 --- a/Library/Homebrew/rubocops/components_redundancy_cop.rb +++ b/Library/Homebrew/rubocops/components_redundancy_cop.rb @@ -13,19 +13,19 @@ module RuboCop HEAD_MSG = "`head` and `head do` should not be simultaneously present".freeze BOTTLE_MSG = "`bottle :modifier` and `bottle do` should not be simultaneously present".freeze - def audit_formula(_node, _class_node, _parent_class_node, formula_class_body_node) - stable_block = find_block(formula_class_body_node, :stable) + def audit_formula(_node, _class_node, _parent_class_node, body_node) + stable_block = find_block(body_node, :stable) if stable_block [:url, :sha256, :mirror].each do |method_name| - problem "`#{method_name}` should be put inside `stable` block" if method_called?(formula_class_body_node, method_name) + problem "`#{method_name}` should be put inside `stable` block" if method_called?(body_node, method_name) end end - problem HEAD_MSG if method_called?(formula_class_body_node, :head) && - find_block(formula_class_body_node, :head) + problem HEAD_MSG if method_called?(body_node, :head) && + find_block(body_node, :head) - problem BOTTLE_MSG if method_called?(formula_class_body_node, :bottle) && - find_block(formula_class_body_node, :bottle) + problem BOTTLE_MSG if method_called?(body_node, :bottle) && + find_block(body_node, :bottle) end end end diff --git a/Library/Homebrew/rubocops/formula_desc_cop.rb b/Library/Homebrew/rubocops/formula_desc_cop.rb index e44c222d87..3414439b03 100644 --- a/Library/Homebrew/rubocops/formula_desc_cop.rb +++ b/Library/Homebrew/rubocops/formula_desc_cop.rb @@ -9,8 +9,8 @@ module RuboCop # - Checks for existence of `desc` # - Checks if size of `desc` > 80 class DescLength < FormulaCop - def audit_formula(_node, _class_node, _parent_class_node, body) - desc_call = find_node_method_by_name(body, :desc) + def audit_formula(_node, _class_node, _parent_class_node, body_node) + desc_call = find_node_method_by_name(body_node, :desc) # Check if a formula's desc is present if desc_call.nil? @@ -48,8 +48,8 @@ module RuboCop xUnit ].freeze - def audit_formula(_node, _class_node, _parent_class_node, body) - desc_call = find_node_method_by_name(body, :desc) + def audit_formula(_node, _class_node, _parent_class_node, body_node) + desc_call = find_node_method_by_name(body_node, :desc) return if desc_call.nil? desc = parameters(desc_call).first diff --git a/Library/Homebrew/rubocops/homepage_cop.rb b/Library/Homebrew/rubocops/homepage_cop.rb index 25c0e9c515..0960074b0f 100644 --- a/Library/Homebrew/rubocops/homepage_cop.rb +++ b/Library/Homebrew/rubocops/homepage_cop.rb @@ -5,8 +5,8 @@ module RuboCop module FormulaAudit # This cop audits `homepage` url in Formulae class Homepage < FormulaCop - def audit_formula(_node, _class_node, _parent_class_node, formula_class_body_node) - homepage_node = find_node_method_by_name(formula_class_body_node, :homepage) + def audit_formula(_node, _class_node, _parent_class_node, body_node) + homepage_node = find_node_method_by_name(body_node, :homepage) homepage = if homepage_node string_content(parameters(homepage_node).first) else