diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 1c7f9d7043..8aeeae26b3 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -414,6 +414,13 @@ module Homebrew if dep.tags.include?(:run) problem "Dependency '#{dep.name}' is marked as :run. Remove :run; it is a no-op." end + + next unless @new_formula + next if formula.versioned_formula? + next unless @official_tap + if dep.tags.include?(:recommended) || dep.tags.include?(:optional) + new_formula_problem "Formulae should not have #{dep.tags} dependencies." + end end end end diff --git a/Library/Homebrew/rubocops/options_cop.rb b/Library/Homebrew/rubocops/options_cop.rb index c162441610..7818787c4a 100644 --- a/Library/Homebrew/rubocops/options_cop.rb +++ b/Library/Homebrew/rubocops/options_cop.rb @@ -46,11 +46,14 @@ module RuboCop module NewFormulaAudit class Options < FormulaCop - MSG = "New Formula should not use `deprecated_option`".freeze + DEP_OPTION = "New Formula should not use `deprecated_option`".freeze + OPTION = "Formula should not have an `option`".freeze def audit_formula(_node, _class_node, _parent_class_node, body_node) return if versioned_formula? - problem MSG if method_called_ever?(body_node, :deprecated_option) + problem DEP_OPTION if method_called_ever?(body_node, :deprecated_option) + return unless formula_tap == "homebrew-core" + problem OPTION if method_called_ever?(body_node, :option) end end end diff --git a/Library/Homebrew/test/rubocops/options_cop_spec.rb b/Library/Homebrew/test/rubocops/options_cop_spec.rb index b888f4315c..d44f044487 100644 --- a/Library/Homebrew/test/rubocops/options_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/options_cop_spec.rb @@ -64,5 +64,15 @@ describe RuboCop::Cop::NewFormulaAudit::Options do end RUBY end + + it "with options" do + expect_offense(<<~RUBY, "/homebrew-core/") + class Foo < Formula + url 'http://example.com/foo-1.0.tgz' + option "with-examples" + ^^^^^^^^^^^^^^^^^^^^^^ Formula should not have an `option` + end + RUBY + end end end