diff options
| author | Xu Cheng | 2015-05-31 18:40:28 +0800 |
|---|---|---|
| committer | Xu Cheng | 2015-06-01 20:08:41 +0800 |
| commit | 4cc21fb1f75a8605e72cdc8d15696d19d2b4bc14 (patch) | |
| tree | 5e43776571c61422e10ac330c185384b21639f3b /Library/Homebrew/cmd | |
| parent | 938dc356c1ec51a0cd826d901ec58777c89493cb (diff) | |
| download | brew-4cc21fb1f75a8605e72cdc8d15696d19d2b4bc14.tar.bz2 | |
audit: audit formulae with the same name
Closes Homebrew/homebrew#40216.
Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/audit.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index 94f77b26b..a31528a0f 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -2,6 +2,8 @@ require "formula" require "utils" require "extend/ENV" require "formula_cellar_checks" +require "official_taps" +require "cmd/search" module Homebrew def audit @@ -161,6 +163,41 @@ class FormulaAuditor @@aliases ||= Formula.aliases + def audit_formula_name + return unless @strict + # skip for non-official taps + return if !formula.core_formula? && !formula.tap.to_s.start_with?("homebrew") + + name = formula.name + full_name = formula.full_name + + if @@aliases.include? name + problem "Formula name is conflicted with existed aliases." + return + end + + if !formula.core_formula? && Formula.core_names.include?(name) + problem "Formula name is conflicted with existed core formula." + return + end + + same_name_tap_formulae = Formula.tap_names.select { |f| f =~ %r{^homebrew/[^/]+/#{name}$} } + homebrew_tapd = HOMEBREW_LIBRARY/"Taps/homebrew" + current_taps = if homebrew_tapd.directory? + homebrew_tapd.subdirs.map(&:basename).map { |tap| tap.to_s.sub(/^homebrew-/, "") } + else + [] + end + same_name_tap_formulae += (OFFICIAL_TAPS - current_taps).map do |tap| + Thread.new { Homebrew.search_tap "homebrew", tap, name } + end.map(&:value).flatten + same_name_tap_formulae.delete(full_name) + + if same_name_tap_formulae.size > 0 + problem "Formula name is conflicted with #{same_name_tap_formulae.join ", "}" + end + end + def audit_deps @specs.each do |spec| # Check for things we don't like to depend on. @@ -716,6 +753,7 @@ class FormulaAuditor def audit audit_file + audit_formula_name audit_class audit_specs audit_desc |
