From 9949482fc80451b7ffe24259d7f7b7685ebf1fb8 Mon Sep 17 00:00:00 2001 From: Dustin Rodrigues Date: Mon, 24 Aug 2020 07:39:07 -0400 Subject: [PATCH] style: don't allow both sha256 and tag/revision in a formula --- Library/Homebrew/rubocops/components_redundancy.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Library/Homebrew/rubocops/components_redundancy.rb b/Library/Homebrew/rubocops/components_redundancy.rb index d0d6298d50..25088fb982 100644 --- a/Library/Homebrew/rubocops/components_redundancy.rb +++ b/Library/Homebrew/rubocops/components_redundancy.rb @@ -18,6 +18,19 @@ module RuboCop STABLE_MSG = "`stable do` should not be present without a `head` or `devel` spec" def audit_formula(_node, _class_node, _parent_class_node, body_node) + urls = find_method_calls_by_name(body_node, :url) + + urls.each do |url| + url.arguments.each do |arg| + next if arg.class != RuboCop::AST::HashNode + + url_args = arg.keys.each.map(&:value) + if method_called?(body_node, :sha256) && url_args.include?(:tag) && url_args.include?(:revision) + problem "Do not use both sha256 and tag/revision." + end + end + end + stable_block = find_block(body_node, :stable) if stable_block [:url, :sha256, :mirror].each do |method_name|