From af42deca4ab70816216ffc060f3aa8f55e469cac Mon Sep 17 00:00:00 2001 From: Martin Afanasjew Date: Tue, 7 Jun 2016 17:46:40 +0200 Subject: audit: detect more 'pkgshare' candidates (#328) The new check also allows the `+` operator instead of our (still heavily preferred) `/` operator for path concatenation and also triggers if the operator is surrounded by whitespace. Also recognizes single-quoted strings and uses a back reference to match the closing quote for a slightly lower chance of false positives. Closes #322.--- Library/Homebrew/cmd/audit.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index 6743f2a46..39d58a146 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -919,8 +919,8 @@ class FormulaAuditor problem "Use \#{pkgshare} instead of \#{share}/#{formula.name}" end - if line =~ %r{share/"#{Regexp.escape(formula.name)}[/'"]} - problem "Use pkgshare instead of (share/\"#{formula.name}\")" + if line =~ %r{share(\s*[/+]\s*)(['"])#{Regexp.escape(formula.name)}(?:\2|/)} + problem "Use pkgshare instead of (share#{$1}\"#{formula.name}\")" end end end -- cgit v1.2.3