diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 0efd28627f..e76bd1e97d 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -386,10 +386,10 @@ module Homebrew problem "Dependency '#{dep.name}' is an alias; use the canonical name '#{dep.to_formula.full_name}'." end - if @new_formula && dep_f.keg_only_reason && - !["openssl", "apr", "apr-util"].include?(dep.name) && - !["openblas"].include?(dep.name) && - dep_f.keg_only_reason.reason == :provided_by_macos + if @new_formula && + dep_f.keg_only_reason&.reason == :provided_by_macos && + dep_f.keg_only_reason.valid? && + !["apr", "apr-util", "openblas", "openssl"].include?(dep.name) new_formula_problem( "Dependency '#{dep.name}' may be unnecessary as it is provided " \ "by macOS; try to build this formula without it.", diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 548a6c4316..daf5cf6d0e 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -252,7 +252,7 @@ module Homebrew its(:problems) { are_expected.to be_empty } end - describe "which is not whitelisted" do + describe "which is not whitelisted", :needs_macos do subject { fa } let(:fa) do