diff options
| author | Martin Afanasjew | 2016-06-07 17:46:40 +0200 |
|---|---|---|
| committer | Martin Afanasjew | 2016-06-07 17:46:40 +0200 |
| commit | af42deca4ab70816216ffc060f3aa8f55e469cac (patch) | |
| tree | 0d52f5d0935a3d0b3d3c917757be6ac199bd6834 | |
| parent | 2cd81e50513f96a657454031e52fa4aec773ea97 (diff) | |
| download | brew-af42deca4ab70816216ffc060f3aa8f55e469cac.tar.bz2 | |
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.
| -rw-r--r-- | Library/Homebrew/cmd/audit.rb | 4 |
1 files changed, 2 insertions, 2 deletions
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 |
