From a5bed1ea312fb3936b5cd2f5b530fa5b841948a3 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 6 Mar 2014 20:40:15 +0000 Subject: [PATCH] audit: check for good with/without usage. Signed-off-by: Mike McQuaid --- Library/Homebrew/cmd/audit.rb | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index 1a81a55d1a..dfc8f17c4c 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -435,16 +435,32 @@ class FormulaAuditor problem "Use 'build.head?' instead of inspecting 'version'" end - if line =~ /build\.include\?\s+['"]\-\-(.*)['"]/ + if line =~ /build\.include\?[\s\(]+['"]\-\-(.*)['"]/ problem "Reference '#{$1}' without dashes" end - if line =~ /build\.with\?\s+['"]-?-?with-(.*)['"]/ - problem "No double 'with': Use `build.with? '#{$1}'` to check for \"--with-#{$1}\"" + if line =~ /build\.include\?[\s\(]+['"]with(out)?-(.*)['"]/ + problem "Use build.with#{$1}? \"#{$2}\" instead of build.include? 'with#{$1}-#{$2}'" end - if line =~ /build\.without\?\s+['"]-?-?without-(.*)['"]/ - problem "No double 'without': Use `build.without? '#{$1}'` to check for \"--without-#{$1}\"" + if line =~ /build\.with\?[\s\(]+['"]-?-?with-(.*)['"]/ + 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 if line =~ /ARGV\.(?!(debug\?|verbose\?|value[\(\s]))/