mirror of
https://github.com/github/codeql.git
synced 2026-04-25 00:35:20 +02:00
JS: fixup double reporting of alerts
This commit is contained in:
@@ -73,6 +73,19 @@ predicate isConstantBooleanReturnValue(Expr e) {
|
||||
isConstantBooleanReturnValue(e.(LogNotExpr).getOperand())
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `e` is a defensive expression with a fixed outcome.
|
||||
*/
|
||||
predicate isConstantDefensive(Expr e) {
|
||||
exists(Expr defensive |
|
||||
defensive = e or
|
||||
// traverse negations
|
||||
defensive.(LogNotExpr).getOperand+() = e
|
||||
|
|
||||
exists(defensive.flow().(DefensiveExpression).getTheTestResult())
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `e` is an expression that should not be flagged as a useless condition.
|
||||
*
|
||||
@@ -87,7 +100,7 @@ predicate isConstantBooleanReturnValue(Expr e) {
|
||||
predicate whitelist(Expr e) {
|
||||
isConstant(e) or
|
||||
isConstant(e.(LogNotExpr).getOperand()) or
|
||||
exists (e.flow().(DefensiveExpression).getTheTestResult()) or
|
||||
isConstantDefensive(e) or // flagged by js/useless-defensive-code
|
||||
isInitialParameterUse(e) or
|
||||
isConstantBooleanReturnValue(e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user