Skip to content
Snippets Groups Projects
Commit a6329944 authored by Jack Nagel's avatar Jack Nagel
Browse files

Audit conditional deps that can be made declarative

parent 51023ef1
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment