From e825f597544f4610995eaec50e10426d012e71bb Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 19 May 2016 20:38:46 +0100 Subject: [PATCH] audit: check for block inreplace with single sub. (#254) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are unnecessarily verbose, have been documented to be avoided and it’s good to nudge people towards the other style. --- 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 d252909d05..4357cc0984 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -182,6 +182,10 @@ class FormulaAuditor problem "'__END__' was found, but 'DATA' is not used" end + if text =~ /inreplace [^\n]* do [^\n]*\n[^\n]*\.gsub![^\n]*\n\ *end/m + problem "'inreplace ... do' was used for a single substitution (use the non-block form instead)." + end + unless text.has_trailing_newline? problem "File should end with a newline" end