Skip to content

Commit dcad2a3

Browse files
author
Max Schaefer
committed
JavaScript: Simplify an if condition.
By pulling this out of the condition we can avoid computing its negation for the `else` branch, which could previously lead to quite an enormous pipeline.
1 parent f4ec168 commit dcad2a3

File tree

1 file changed

+6
-4
lines changed
  • javascript/ql/src/semmle/javascript/frameworks

1 file changed

+6
-4
lines changed

javascript/ql/src/semmle/javascript/frameworks/Express.qll

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,12 @@ module Express {
127127
Expr getRouteHandlerExpr(int index) {
128128
// The first argument is a URI pattern if it is a string. If it could possibly be
129129
// a function, we consider it to be a route handler, otherwise a URI pattern.
130-
if getArgument(0).analyze().getAType() = TTFunction() then
131-
result = getArgument(index)
132-
else
133-
(index >= 0 and result = getArgument(index + 1))
130+
exists (AnalyzedNode firstArg | firstArg = getArgument(0).analyze() |
131+
if firstArg.getAType() = TTFunction() then
132+
result = getArgument(index)
133+
else
134+
(index >= 0 and result = getArgument(index + 1))
135+
)
134136
}
135137

136138
/** Gets an argument that represents a route handler being registered. */

0 commit comments

Comments
 (0)