From e9043abc5784c0ae442479f097d75750f9ac3a09 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Tue, 7 Sep 2010 14:34:39 -0700 Subject: [PATCH] brew-audit - catch more interpolation style issues --- Library/Contributions/examples/brew-audit.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Library/Contributions/examples/brew-audit.rb b/Library/Contributions/examples/brew-audit.rb index 666d524231..b9c36e00b5 100755 --- a/Library/Contributions/examples/brew-audit.rb +++ b/Library/Contributions/examples/brew-audit.rb @@ -19,7 +19,7 @@ def audit_formula_text text problems << " * Remove 'use_mirror' from url." end - # 2 (or more, if in an if block) spaces before depends_on, please + # 2 (or more in an if block) spaces before depends_on, please if text =~ /^\ ?depends_on/ problems << " * Check indentation of 'depends_on'." end @@ -29,6 +29,11 @@ def audit_formula_text text problems << " * Don't need 'FileUtils.' before #{$1}." end + # Check for string interpolation of single values. + if text =~ /(system|inreplace|gsub!|change_make_var!) .* ['"]#\{(\w+)\}['"]/ + problems << " * Don't need to interpolate \"#{$2}\" with #{$1}" + end + # Check for string concatenation; prefer interpolation if text =~ /(#\{\w+\s*\+\s*['"][^}]+\})/ problems << " * Try not to concatenate paths in string interpolation:\n #{$1}"