diff options
| author | Adam Vandenberg | 2010-09-07 14:34:39 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2010-09-07 14:36:51 -0700 |
| commit | e9043abc5784c0ae442479f097d75750f9ac3a09 (patch) | |
| tree | 85e695adf9b49e31a41ad6d2bd8e856400bf06e3 | |
| parent | 2bb9fa1b2221e4ee2bf08db0f30ee80a7944b057 (diff) | |
| download | brew-e9043abc5784c0ae442479f097d75750f9ac3a09.tar.bz2 | |
brew-audit - catch more interpolation style issues
| -rwxr-xr-x | Library/Contributions/examples/brew-audit.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Library/Contributions/examples/brew-audit.rb b/Library/Contributions/examples/brew-audit.rb index 666d52423..b9c36e00b 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}" |
