Skip to content

Commit

Permalink
#29865 sonarq feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jdotcms committed Sep 18, 2024
1 parent 0a0c7f0 commit 42c1a12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions dotCMS/src/main/java/com/dotcms/analytics/Util.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.dotcms.analytics;

import com.dotmarketing.beans.Host;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.cms.urlmap.UrlMapContext;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.PageMode;
import io.vavr.control.Try;

import static com.dotcms.exception.ExceptionUtil.getErrorMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class FilterParser {

private static final String EXPRESSION_REGEX = "(\\w+\\.\\w+)\\s*(=|!=|in|!in)\\s*\\['(.*?)'";
private static final String LOGICAL_OPERATOR_REGEX = "\\s*(and|or)\\s*";
private static final Pattern TOKEN_PATTERN = Pattern.compile(EXPRESSION_REGEX);
private static final Pattern LOGICAL_PATTERN = Pattern.compile(LOGICAL_OPERATOR_REGEX);

static class Token {
String member;
Expand Down Expand Up @@ -48,8 +50,7 @@ public static Tuple2<List<Token>,List<LogicalOperator>> parseFilterExpression(fi
final List<Token> tokens = new ArrayList<>();
final List<LogicalOperator> logicalOperators = new ArrayList<>();
// note:Need to use cache here
final Pattern tokenPattern = Pattern.compile(EXPRESSION_REGEX);
final Matcher tokenMatcher = tokenPattern.matcher(expression);
final Matcher tokenMatcher = TOKEN_PATTERN.matcher(expression);

// Extract the tokens (member, operator, values)
while (tokenMatcher.find()) {
Expand All @@ -61,8 +62,7 @@ public static Tuple2<List<Token>,List<LogicalOperator>> parseFilterExpression(fi

// Pattern for logical operators (and, or)
// Need to use cache here
final Pattern logicalPattern = Pattern.compile(LOGICAL_OPERATOR_REGEX);
final Matcher logicalMatcher = logicalPattern.matcher(expression);
final Matcher logicalMatcher = LOGICAL_PATTERN.matcher(expression);

// Extract logical operators
while (logicalMatcher.find()) {
Expand Down

0 comments on commit 42c1a12

Please sign in to comment.