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.
This commit is contained in:
parent
2cd81e5051
commit
af42deca4a
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user