mirror of
https://github.com/github/codeql.git
synced 2026-04-27 09:45:15 +02:00
Ruby: Remove redundant predicate
The existing barrier guard machinery recognises guards such as `if x and y`, so there's no need to explicitly model them.
This commit is contained in:
@@ -35,8 +35,6 @@ private predicate stringConstCompare(CfgNodes::AstCfgNode guard, CfgNode testedN
|
||||
stringConstCompareOr(guard, def, branch) and
|
||||
stringConstCompare(g.getLeftOperand(), testedNode, _)
|
||||
)
|
||||
or
|
||||
stringConstCompareAnd(guard, testedNode, branch)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,23 +55,6 @@ private predicate stringConstCompareOr(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `guard` is an `and` expression containing a string comparison guard in either operand.
|
||||
* For example:
|
||||
*
|
||||
* ```rb
|
||||
* x == "foo" and other_condition()
|
||||
* other_condition() and x == "foo"
|
||||
* ```
|
||||
*/
|
||||
private predicate stringConstCompareAnd(
|
||||
CfgNodes::ExprNodes::BinaryOperationCfgNode guard, CfgNode testedNode, boolean branch
|
||||
) {
|
||||
guard.getExpr() instanceof LogicalAndExpr and
|
||||
branch = true and
|
||||
stringConstCompare(guard.getAnOperand(), testedNode, branch)
|
||||
}
|
||||
|
||||
/**
|
||||
* A validation of value by comparing with a constant string value, for example
|
||||
* in:
|
||||
|
||||
Reference in New Issue
Block a user