audit: audit formulae with the same name
Closes Homebrew/homebrew#40216. Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
parent
938dc356c1
commit
4cc21fb1f7
@ -2,6 +2,8 @@ require "formula"
|
|||||||
require "utils"
|
require "utils"
|
||||||
require "extend/ENV"
|
require "extend/ENV"
|
||||||
require "formula_cellar_checks"
|
require "formula_cellar_checks"
|
||||||
|
require "official_taps"
|
||||||
|
require "cmd/search"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def audit
|
def audit
|
||||||
@ -161,6 +163,41 @@ class FormulaAuditor
|
|||||||
|
|
||||||
@@aliases ||= Formula.aliases
|
@@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
|
def audit_deps
|
||||||
@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.
|
||||||
@ -716,6 +753,7 @@ class FormulaAuditor
|
|||||||
|
|
||||||
def audit
|
def audit
|
||||||
audit_file
|
audit_file
|
||||||
|
audit_formula_name
|
||||||
audit_class
|
audit_class
|
||||||
audit_specs
|
audit_specs
|
||||||
audit_desc
|
audit_desc
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user