if (x.getOperator() == SQLBinaryOperator.Like && leftResult instanceof String && leftResult.equals(rightResult)) {
addViolation(visitor, ErrorCode.SAME_CONST_LIKE, "same const like", x);
}
if (x.getOperator() == SQLBinaryOperator.Like || x.getOperator() == SQLBinaryOperator.NotLike) {
WallContext context = WallContext.current();
if (context != null) {
if (rightResult instanceof Number || leftResult instanceof Number) {
context.incrementLikeNumberWarnnings();
}
}
}
if (x.getOperator() == SQLBinaryOperator.BooleanAnd) {
if (visitor != null && !visitor.getConfig().isConditionDoubleConstAllow()) {
if (rightResult != null && x.getLeft() instanceof SQLBinaryOpExpr) {
SQLBinaryOpExpr leftBinaryOpExpr = (SQLBinaryOpExpr) x.getLeft();
if (leftBinaryOpExpr.getOperator() != SQLBinaryOperator.BooleanAnd //
&& leftBinaryOpExpr.getOperator() != SQLBinaryOperator.BooleanOr //
&& leftResult != null //
&& visitor != null) {
addViolation(visitor, ErrorCode.DOUBLE_CONST_CONDITION, "double const condition", x);
}
if (leftBinaryOpExpr.getOperator() == SQLBinaryOperator.BooleanAnd //
|| leftBinaryOpExpr.getOperator() == SQLBinaryOperator.BooleanOr) {
Object leftRightVal = getValue(leftBinaryOpExpr.getRight());
if (leftRightVal != null) {
addViolation(visitor, ErrorCode.DOUBLE_CONST_CONDITION, "double const condition", x);
}
}
}
}
if (leftResult == Boolean.TRUE) {
if (!isFirst(x.getLeft())) {
final WallConditionContext current = wallConditionContextLocal.get();
if (current != null) {
current.setPartAlwayTrue(true);
}
}
} else if (rightResult == Boolean.TRUE) {
final WallConditionContext current = wallConditionContextLocal.get();
boolean isLikeAlwayTrue = false;
if (right instanceof SQLBinaryOpExpr
&& ((SQLBinaryOpExpr) right).getOperator() == SQLBinaryOperator.Like) {
isLikeAlwayTrue = true;
}
if (current != null && !isLikeAlwayTrue) {
current.setPartAlwayTrue(true);
}
}
if (Boolean.TRUE == leftResult && Boolean.TRUE == rightResult) {
return true;
}
if (Boolean.FALSE == leftResult || Boolean.FALSE == rightResult) {
return false;
}
}
String dbType = null;
WallContext wallContext = WallContext.current();
if (wallContext != null) {
dbType = wallContext.getDbType();
}
return eval(dbType, x, Collections.emptyList());
}