From 8f47bdb782e3d6d5d1bfa39910197d5a7975c7d4 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Sat, 17 Mar 2012 08:45:51 -0700 Subject: [PATCH] audit: check for install options being shadowed --- Library/Homebrew/cmd/audit.rb | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index b5e5159298..a7376c8036 100755 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -125,16 +125,31 @@ def audit_formula_text name, text return problems 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 problems = [] - # Find possible options + # Textually find options checked for in the formula options = [] text.scan(/ARGV\.include\?[ ]*\(?(['"])(.+?)\1/) { |m| options << m[1] } options.reject! {|o| o.include? "#"} - options.uniq! + options.uniq! # May be checked more than once - # Find documented options + # Find declared options begin opts = f.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 == '--32-bit' and text =~ /ARGV\.build_32_bit\?/ 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