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.
This commit is contained in:
Dominyk Tiller 2017-10-08 06:54:49 +01:00
parent 30ac040865
commit 2a25825a12
No known key found for this signature in database
GPG Key ID: FE19AEFCF658C6F6

View File

@ -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 <path_to_file>, :exist?` instead of `#{Regexp.last_match(1)}`"
end
if line =~ /(assert !File\.exist\?|!File\.exist\?)/
problem "Use `refute_predicate <path_to_file>, :exist?` instead of `#{Regexp.last_match(1)}`"
if line =~ /assert !File\.exist\?/
problem "Use `refute_predicate <path_to_file>, :exist?` instead of `assert !File.exist?`"
end
return unless @strict