From 92d224f0fcb6943d274940d50a76b72125af960e Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Thu, 1 Jul 2021 18:38:54 +0100 Subject: [PATCH] rubocops/lines: check allowlist for use of `ENV.runtime_cpu_detection` This is implements the first audit discussed in #11608. --- Library/Homebrew/rubocops/lines.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Library/Homebrew/rubocops/lines.rb b/Library/Homebrew/rubocops/lines.rb index 3bc725df760b4..5b8f586b42f32 100644 --- a/Library/Homebrew/rubocops/lines.rb +++ b/Library/Homebrew/rubocops/lines.rb @@ -540,6 +540,13 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node) problem "macOS has been 64-bit only since 10.6 so ENV.universal_binary is deprecated." end + find_instance_method_call(body_node, "ENV", :runtime_cpu_detection) do + next if tap_style_exception? :runtime_cpu_detection_allowlist + + problem "Formulae should be verified as having support for runtime hardware detection before " \ + "using ENV.runtime_cpu_detection." + end + find_every_method_call_by_name(body_node, :depends_on).each do |method| next unless method_called?(method, :new)