From 544dc1b0d00ad05006a75eb546994954e3b618f0 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 7 Apr 2018 20:41:25 +0100 Subject: [PATCH] audit: check for build.with? dependencies. These don't behave as expected; depending on when and where in Homebrew (or even an installation process) these are evaluated they return different results. This means that sometimes these will be seen as dependencies and sometimes they will be ignored entirely by the DSL. Instead `:optional` or `:recommended` dependencies should be used. We don't have a solution yet for grouping dependencies together but this is another case for removing more optional dependencies altogether (as there are no designs or proposed implementations). --- Library/Homebrew/dev-cmd/audit.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 5eaffe2afa..4a6362b68c 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -738,6 +738,10 @@ class FormulaAuditor problem "Use \#{pkgshare} instead of \#{share}/#{formula.name}" end + if line =~ /depends_on .+ if build\.with(out)?\?\(?["']\w+["']\)?/ + problem "`Use :optional` or `:recommended` instead of `#{Regexp.last_match(0)}`" + end + return unless line =~ %r{share(\s*[/+]\s*)(['"])#{Regexp.escape(formula.name)}(?:\2|/)} problem "Use pkgshare instead of (share#{Regexp.last_match(1)}\"#{formula.name}\")" end