From 2a25825a12897b7bfa167a720f24b6df03bdca94 Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Sun, 8 Oct 2017 06:54:49 +0100 Subject: [PATCH] audit: tweak assert/refute_predicate audit Addresses some of the issues I raised in https://github.com/Homebrew/homebrew-core/pull/19127#issue-263566817. Would still like to work out a way to check `File.exist?`-style language inside the `test do` block exclusively but for now it's better to be too conservative on the audit than to be overly-zealous and flag too much. --- Library/Homebrew/dev-cmd/audit.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index ee5fb8df81..16ae7cba10 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -967,12 +967,12 @@ class FormulaAuditor problem "Use `assert_match` instead of `assert ...include?`" end - if line =~ /(assert File\.exist\?|File\.exist\?)/ + if line =~ /(assert File\.exist\?|assert \(.*\)\.exist\?)/ problem "Use `assert_predicate , :exist?` instead of `#{Regexp.last_match(1)}`" end - if line =~ /(assert !File\.exist\?|!File\.exist\?)/ - problem "Use `refute_predicate , :exist?` instead of `#{Regexp.last_match(1)}`" + if line =~ /assert !File\.exist\?/ + problem "Use `refute_predicate , :exist?` instead of `assert !File.exist?`" end return unless @strict