From bf8ff2dcb72649ae87d4561ceef4e0a590bdea60 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 29 Mar 2014 09:16:27 -0500 Subject: [PATCH] audit: check the use of Dir[] Sometimes `Dir[]` is used with single files/directories unnecessarily. --- Library/Homebrew/cmd/audit.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index db56663a4a..721f6c9873 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -525,6 +525,10 @@ class FormulaAuditor if line =~ /depends_on ['"](.+)['"] (if.+|unless.+)$/ audit_conditional_dep($1, $2, $&) end + + if line =~ /(Dir\[("[^\*{},]+")\])/ + problem "#{$1} is unnecessary; just use #{$2}" + end end def audit_conditional_dep(dep, condition, line)