diff options
| author | Jack Nagel | 2013-07-16 20:38:50 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-07-16 21:24:54 -0500 |
| commit | a6329944031c1e5af821272fda9aada1b994d77e (patch) | |
| tree | 3df387391ed099ede79e898bf8feb479c56e2bd4 /Library/Homebrew/cmd | |
| parent | 51023ef15b7cafa3a367ef6505fbfc7b0cefdc65 (diff) | |
| download | brew-a6329944031c1e5af821272fda9aada1b994d77e.tar.bz2 | |
Audit conditional deps that can be made declarative
Diffstat (limited to 'Library/Homebrew/cmd')
| -rw-r--r-- | Library/Homebrew/cmd/audit.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index ae5b2410a..3e3075313 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -493,6 +493,27 @@ class FormulaAuditor if text =~ /ENV.fortran/ problem "Use `depends_on :fortran` instead of `ENV.fortran`" end + + if text =~ /depends_on :(.+) (if.+|unless.+)$/ + audit_conditional_dep($1.to_sym, $2, $&) + end + + if text =~ /depends_on ['"](.+)['"] (if.+|unless.+)$/ + audit_conditional_dep($1, $2, $&) + end + end + + def audit_conditional_dep(dep, condition, line) + case condition + when /if build\.include\? ['"]with-#{dep}['"]$/, /if build\.with\? ['"]#{dep}['"]$/ + problem %{Replace #{line.inspect} with "depends_on #{quote_dep(dep)} => :optional"} + when /unless build\.include\? ['"]without-#{dep}['"]$/, /unless build\.without\? ['"]#{dep}['"]$/ + problem %{Replace #{line.inspect} with "depends_on #{quote_dep(dep)} => :recommended"} + end + end + + def quote_dep(dep) + Symbol === dep ? dep.inspect : "'#{dep}'" end def audit_python |
