mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
Java: Update 2 queries.
This commit is contained in:
@@ -12,8 +12,9 @@
|
||||
|
||||
import java
|
||||
|
||||
from MulExpr e
|
||||
from MulExpr e, RemExpr lhs
|
||||
where
|
||||
e.getLeftOperand() instanceof RemExpr and
|
||||
e.getLeftOperand() = lhs and
|
||||
not lhs.isParenthesized() and
|
||||
e.getRightOperand().getType().hasName("int")
|
||||
select e, "Result of a remainder operation multiplied by an integer."
|
||||
|
||||
@@ -120,12 +120,24 @@ predicate endOfBinaryLhs(BinaryExpr expr, int line, int col) {
|
||||
)
|
||||
}
|
||||
|
||||
/** Compute the number of parenthesis characters next to the operator. */
|
||||
int getParensNextToOp(BinaryExpr expr) {
|
||||
exists(Expr left, Expr right, int pleft, int pright |
|
||||
left = expr.getLeftOperand() and
|
||||
right = expr.getRightOperand() and
|
||||
(if left.isParenthesized() then isParenthesized(left, pleft) else pleft = 0) and
|
||||
(if right.isParenthesized() then isParenthesized(right, pright) else pright = 0) and
|
||||
result = pleft + pright
|
||||
)
|
||||
}
|
||||
|
||||
/** Compute whitespace around the operator. */
|
||||
int operatorWS(BinaryExpr expr) {
|
||||
exists(int line, int lcol, int rcol |
|
||||
exists(int line, int lcol, int rcol, int parens |
|
||||
endOfBinaryLhs(expr, line, lcol) and
|
||||
startOfBinaryRhs(expr, line, rcol) and
|
||||
result = rcol - lcol + 1 - expr.getOp().length()
|
||||
parens = getParensNextToOp(expr) and
|
||||
result = rcol - lcol + 1 - expr.getOp().length() - parens
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user