mirror of
https://github.com/github/codeql.git
synced 2026-04-23 07:45:17 +02:00
ruby: remove redundant cases
The CFG handles the negation
This commit is contained in:
@@ -37,23 +37,12 @@ predicate isGuarded(LocalVariableReadAccess read) {
|
||||
guard.getAstNode() = read.getVariable().getAnAccess() and
|
||||
branch = true
|
||||
or
|
||||
// guard is `!var`
|
||||
guard.getAstNode().(NotExpr).getOperand() = read.getVariable().getAnAccess() and
|
||||
branch = false
|
||||
or
|
||||
// guard is `var.nil?`
|
||||
exists(MethodCall c | guard.getAstNode() = c |
|
||||
c.getReceiver() = read.getVariable().getAnAccess() and
|
||||
c.getMethodName() = "nil?"
|
||||
) and
|
||||
branch = false
|
||||
or
|
||||
// guard is `!var.nil?`
|
||||
exists(MethodCall c | guard.getAstNode().(NotExpr).getOperand() = c |
|
||||
c.getReceiver() = read.getVariable().getAnAccess() and
|
||||
c.getMethodName() = "nil?"
|
||||
) and
|
||||
branch = true
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user