style: don't allow both sha256 and tag/revision in a formula

This commit is contained in:
Dustin Rodrigues 2020-08-24 07:39:07 -04:00
parent a6744d2ee9
commit 9949482fc8

View File

@ -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|