audit: check for optional and recommended requirements on new formulae

This commit is contained in:
commitay 2018-07-11 23:21:41 +10:00
parent e1957a9d04
commit ab8054482b

View File

@ -363,6 +363,7 @@ module Homebrew
@specs.each do |spec| @specs.each do |spec|
# Check for things we don't like to depend on. # Check for things we don't like to depend on.
# We allow non-Homebrew installs whenever possible. # We allow non-Homebrew installs whenever possible.
options_message = "Formulae should not have optional or recommended dependencies"
spec.deps.each do |dep| spec.deps.each do |dep|
begin begin
dep_f = dep.to_formula dep_f = dep.to_formula
@ -419,9 +420,15 @@ module Homebrew
next unless @new_formula next unless @new_formula
next unless @official_tap next unless @official_tap
if dep.tags.include?(:recommended) || dep.tags.include?(:optional) if dep.tags.include?(:recommended) || dep.tags.include?(:optional)
new_formula_problem "Formulae should not have #{dep.tags} dependencies." new_formula_problem options_message
end end
end end
next unless @new_formula
next unless @official_tap
if spec.requirements.map(&:recommended?).any? || spec.requirements.map(&:optional?).any?
new_formula_problem options_message
end
end end
end end