diff options
| author | Adam Vandenberg | 2010-08-10 13:04:51 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2010-08-10 13:04:51 -0700 |
| commit | ff0ea323b5b3b9491f78d0c53e240ec777b9ad95 (patch) | |
| tree | a95b5fff2a643c4a7c740a39efd34bb7b3d6147f | |
| parent | b12cc1eb0acc0daea2e355c450aa8b9dbf5b2743 (diff) | |
| download | brew-ff0ea323b5b3b9491f78d0c53e240ec777b9ad95.tar.bz2 | |
brew audit - check used and documented options
| -rwxr-xr-x | Library/Contributions/examples/brew-audit.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Library/Contributions/examples/brew-audit.rb b/Library/Contributions/examples/brew-audit.rb index 84334a95b..916f93d8f 100755 --- a/Library/Contributions/examples/brew-audit.rb +++ b/Library/Contributions/examples/brew-audit.rb @@ -60,6 +60,40 @@ def audit_formula_text text return problems end +def audit_formula_options f, text + problems = [] + + # Find possible options + options = [] + text.scan(/ARGV\.include\?[ ]*\(?(['"])(.+?)\1/) { |m| options << m[1] } + options.reject! {|o| o.include? "#"} + options.uniq! + + # Find documented options + begin + opts = f.options + documented_options = [] + opts.each{ |o| documented_options << o[0] } + documented_options.reject! {|o| o.include? "="} + rescue + documented_options = [] + end + + if options.length > 0 + options.each do |o| + problems << " * Option #{o} is not documented" unless documented_options.include? o + end + end + + if documented_options.length > 0 + documented_options.each do |o| + problems << " * Option #{o} is unused" unless options.include? o + end + end + + return problems +end + def audit_some_formulae ff.each do |f| problems = [] @@ -82,6 +116,7 @@ def audit_some_formulae text_without_patch = (text.split("__END__")[0]).strip() problems += audit_formula_text(text_without_patch) + problems += audit_formula_options(f, text_without_patch) unless problems.empty? puts "#{f.name}:" |
