audit: check for install options being shadowed

This commit is contained in:
Adam Vandenberg 2012-03-17 08:45:51 -07:00
parent 5141c9cadd
commit 8f47bdb782

View File

@ -125,16 +125,31 @@ def audit_formula_text name, text
return problems return problems
end end
INSTALL_OPTIONS = %W[
--build-from-source
--debug
--devel
--force
--fresh
--HEAD
--ignore-dependencies
--interactive
--use-clang
--use-gcc
--use-llvm
--verbose
].freeze
def audit_formula_options f, text def audit_formula_options f, text
problems = [] problems = []
# Find possible options # Textually find options checked for in the formula
options = [] options = []
text.scan(/ARGV\.include\?[ ]*\(?(['"])(.+?)\1/) { |m| options << m[1] } text.scan(/ARGV\.include\?[ ]*\(?(['"])(.+?)\1/) { |m| options << m[1] }
options.reject! {|o| o.include? "#"} options.reject! {|o| o.include? "#"}
options.uniq! options.uniq! # May be checked more than once
# Find documented options # Find declared options
begin begin
opts = f.options opts = f.options
documented_options = [] documented_options = []
@ -156,6 +171,9 @@ def audit_formula_options f, text
next if o == '--universal' and text =~ /ARGV\.build_universal\?/ next if o == '--universal' and text =~ /ARGV\.build_universal\?/
next if o == '--32-bit' and text =~ /ARGV\.build_32_bit\?/ next if o == '--32-bit' and text =~ /ARGV\.build_32_bit\?/
problems << " * Option #{o} is unused" unless options.include? o problems << " * Option #{o} is unused" unless options.include? o
if INSTALL_OPTIONS.include? o
problems << " * Option #{o} shadows an install option; should be renamed"
end
end end
end end