audit: check for good with/without usage.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Mike McQuaid 2014-03-06 20:40:15 +00:00
parent 1070acfe7a
commit a5bed1ea31

View File

@ -435,16 +435,32 @@ class FormulaAuditor
problem "Use 'build.head?' instead of inspecting 'version'" problem "Use 'build.head?' instead of inspecting 'version'"
end end
if line =~ /build\.include\?\s+['"]\-\-(.*)['"]/ if line =~ /build\.include\?[\s\(]+['"]\-\-(.*)['"]/
problem "Reference '#{$1}' without dashes" problem "Reference '#{$1}' without dashes"
end end
if line =~ /build\.with\?\s+['"]-?-?with-(.*)['"]/ if line =~ /build\.include\?[\s\(]+['"]with(out)?-(.*)['"]/
problem "No double 'with': Use `build.with? '#{$1}'` to check for \"--with-#{$1}\"" problem "Use build.with#{$1}? \"#{$2}\" instead of build.include? 'with#{$1}-#{$2}'"
end end
if line =~ /build\.without\?\s+['"]-?-?without-(.*)['"]/ if line =~ /build\.with\?[\s\(]+['"]-?-?with-(.*)['"]/
problem "No double 'without': Use `build.without? '#{$1}'` to check for \"--without-#{$1}\"" problem "Don't duplicate 'with': Use `build.with? \"#{$1}\"` to check for \"--with-#{$1}\""
end
if line =~ /build\.without\?[\s\(]+['"]-?-?without-(.*)['"]/
problem "Don't duplicate 'without': Use `build.without? \"#{$1}\"` to check for \"--without-#{$1}\""
end
if line =~ /unless build\.with(out)?\?/
problem "Don't use unless with 'build.with#{$1}': use 'if build.with#{$1}?'"
end
if line =~ /(not\s|!)\s*build\.with?\?/
problem "Don't negate 'build.without?': use 'build.with?'"
end
if line =~ /(not\s|!)\s*build\.without?\?/
problem "Don't negate 'build.with?': use 'build.without?'"
end end
if line =~ /ARGV\.(?!(debug\?|verbose\?|value[\(\s]))/ if line =~ /ARGV\.(?!(debug\?|verbose\?|value[\(\s]))/