mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
simplify the output file argument
This commit is contained in:
@@ -172,14 +172,28 @@ module UselsesCatCandidates {
|
||||
|
|
||||
(if root.asExpr() instanceof TemplateLiteral then quote = "`" else quote = "\"") and
|
||||
root.getFirstLeaf().getStringValue().prefix(cat.length()) = cat and
|
||||
// Remove an initial ""+ (e.g. in `""+file`)
|
||||
exists(string rawConcat | rawConcat = quote + printed.suffix(cat.length()).trim() |
|
||||
if rawConcat.prefix(3) = "\"\"+" then result = rawConcat.suffix(3) else result = rawConcat
|
||||
result = getSimplifiedStringConcat(rawConcat)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a simplified and equivalent string concatenation for a given string concatenation `str`
|
||||
*/
|
||||
bindingset[str]
|
||||
private string getSimplifiedStringConcat(string str) {
|
||||
// Remove an initial ""+ (e.g. in `""+file`)
|
||||
if str.prefix(3) = "\"\"+" then
|
||||
result = str.suffix(3)
|
||||
// prettify `${newpath}` to just newpath
|
||||
else if str.prefix(3) = "`${" and str.suffix(str.length() - 2) = "}`" and not str.suffix(3).matches("%{%") then
|
||||
result = str.prefix(str.length() - 2).suffix(3)
|
||||
else
|
||||
result = str
|
||||
}
|
||||
|
||||
/**
|
||||
* A call to child_process.exec that might be a useless call to cat.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user