From ccb0e2e2285182006badc74ca7c62f486aca4c9d Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 12 Jul 2024 09:11:22 +0200 Subject: [PATCH] [apex] AvoidNonRestrictiveQueriesRule - reuse SEE_ALL_DATA This is already defined in ASTAnnotationParameter --- .../rule/performance/AvoidNonRestrictiveQueriesRule.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidNonRestrictiveQueriesRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidNonRestrictiveQueriesRule.java index 1d8b91f278..aa51602732 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidNonRestrictiveQueriesRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidNonRestrictiveQueriesRule.java @@ -25,7 +25,6 @@ public class AvoidNonRestrictiveQueriesRule extends AbstractApexRule { private static final Pattern RESTRICTIVE_PATTERN = Pattern.compile("(where )|(limit )", Pattern.CASE_INSENSITIVE); private static final Pattern SELECT_PATTERN = Pattern.compile("(select )", Pattern.CASE_INSENSITIVE); private static final Pattern SUB_QUERY_PATTERN = Pattern.compile("(?i)\\(\\s*select\\s+[^)]+\\)"); - private static final String SEE_ALL_DATA_ANNOTATION_PARAMETER = "SeeAllData"; @Override protected @NonNull RuleTargetSelector buildTargetSelector() { @@ -52,11 +51,11 @@ public class AvoidNonRestrictiveQueriesRule extends AbstractApexRule { .map(NodeStream::first); Optional methodSeeAllData = methodAnnotation.flatMap(m -> m.children(ASTAnnotationParameter.class) - .filter(p -> SEE_ALL_DATA_ANNOTATION_PARAMETER.equalsIgnoreCase(p.getName())) + .filter(p -> ASTAnnotationParameter.SEE_ALL_DATA.equalsIgnoreCase(p.getName())) .firstOpt() .map(ASTAnnotationParameter::getBooleanValue)); boolean classSeeAllData = classAnnotation.flatMap(m -> m.children(ASTAnnotationParameter.class) - .filter(p -> SEE_ALL_DATA_ANNOTATION_PARAMETER.equalsIgnoreCase(p.getName())) + .filter(p -> ASTAnnotationParameter.SEE_ALL_DATA.equalsIgnoreCase(p.getName())) .firstOpt() .map(ASTAnnotationParameter::getBooleanValue)) .orElse(false);