diff --git a/Library/Homebrew/formula_auditor.rb b/Library/Homebrew/formula_auditor.rb index a45d7166f4..55c6d0976f 100644 --- a/Library/Homebrew/formula_auditor.rb +++ b/Library/Homebrew/formula_auditor.rb @@ -318,9 +318,24 @@ module Homebrew conflicting_formula = Formulary.factory(c.name) problem "Formula should not conflict with itself" if formula == conflicting_formula - # Use Formula instead of FormulaConflict to be able correctly handle renamed formulae and aliases - reverse_conflicts = conflicting_formula.conflicts.map { |rc| Formulary.factory(rc.name) } - if reverse_conflicts.exclude? formula + next unless @core_tap + + if CoreTap.instance.formula_renames.key?(c.name) || Formula.aliases.include?(c.name) + problem "Formula conflict should be declared using " \ + "canonical name (#{conflicting_formula.name}) instead of #{c.name}" + end + + rev_conflict_found = false + conflicting_formula.conflicts.each do |rc| + rc_formula = Formulary.factory(rc.name) + if CoreTap.instance.formula_renames.key?(rc.name) || Formula.aliases.include?(rc.name) + problem "Formula #{conflicting_formula.name} conflict should be declared using " \ + "canonical name (#{rc_formula.name}) instead of #{rc.name}" + end + + rev_conflict_found ||= rc_formula == formula + end + unless rev_conflict_found problem "Formula #{conflicting_formula.name} should also have a conflict declared with #{formula.name}" end rescue TapFormulaUnavailableError diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 259e6bd2c1..d9040f4055 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -1142,7 +1142,7 @@ module Homebrew describe "#audit_conflicts" do specify "it warns when conflicting with non-existing formula" do - fa = formula_auditor "foo", <<~RUBY + fa = formula_auditor "foo", <<~RUBY, core_tap: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -1157,7 +1157,7 @@ module Homebrew end specify "it warns when conflicting with itself" do - fa = formula_auditor "foo", <<~RUBY + fa = formula_auditor "foo", <<~RUBY, core_tap: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz" @@ -1172,13 +1172,13 @@ module Homebrew end specify "it warns when another formula does not have a symmetric conflict" do - formula_auditor "bar", <<~RUBY + formula_auditor "bar", <<~RUBY, core_tap: true class Bar < Formula url "https://brew.sh/foo-1.0.tgz" end RUBY - fa = formula_auditor "foo", <<~RUBY + fa = formula_auditor "foo", <<~RUBY, core_tap: true class Foo < Formula url "https://brew.sh/foo-1.0.tgz"