Skip to content

Commit ad70f18

Browse files
committed
[refactor] Address 4 low-risk Codacy findings on this PR
Quick wins picked from the Codacy report — small, mechanical cleanups that do not touch any of the pre-existing NPath complexity territory that @line-o flagged as a conflict-with-other-PRs risk. - FunUnparsedText.java: replace fully-qualified StandardCharsets.UTF_8 with the already-static-imported UTF_8 (UnnecessaryFullyQualifiedName) - FunMatches.java: collapse a nested if into a single condition (CollapsibleIfStatements) - XQueryContext.ModuleVertex.equals: combine the two-step namespace + location comparison into a single && return (SimplifyBooleanReturns) - RegexUtil.java: remove unused convertUnicodeBlockNames(String) private method (UnusedPrivateMethod) -- left over from an early Java-regex implementation attempt before the validation path moved to Saxon The remaining 10 NPath complexity warnings and the AvoidReassigningParameters warnings are left untouched per @line-o's note about pre-existing complexity raising conflict risk with other PRs in the pipeline. Verified: build clean, XQuery3Tests 1026/1026 pass.
1 parent 8c4fbfa commit ad70f18

4 files changed

Lines changed: 6 additions & 22 deletions

File tree

exist-core/src/main/java/org/exist/xquery/XQueryContext.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3874,10 +3874,7 @@ public boolean equals(final Object o) {
38743874
}
38753875

38763876
final ModuleVertex that = (ModuleVertex) o;
3877-
if (!namespaceURI.equals(that.namespaceURI)) {
3878-
return false;
3879-
}
3880-
return location.equals(that.location);
3877+
return namespaceURI.equals(that.namespaceURI) && location.equals(that.location);
38813878
}
38823879

38833880
@Override

exist-core/src/main/java/org/exist/xquery/functions/fn/FunMatches.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,10 @@ private Sequence evalWithIndex(final Sequence contextSequence, final Item contex
441441
// restricted to that QName
442442
contextQName = null;
443443
}
444-
if (!indexFound && contextQName == null) {
445-
// if there are some indexes defined on a qname,
446-
// we need to check them all
447-
if (iflags.hasIndexOnQNames()) {
448-
indexScan = true;
449-
}
450-
// else use range index defined on path by default
444+
// if there are some indexes defined on a qname, we need to check them all;
445+
// otherwise use range index defined on path by default
446+
if (!indexFound && contextQName == null && iflags.hasIndexOnQNames()) {
447+
indexScan = true;
451448
}
452449
} else {
453450
result = evalFallback(nodes, pattern, flags, indexType);

exist-core/src/main/java/org/exist/xquery/functions/fn/FunUnparsedText.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ private Charset getCharset(final String encoding, final Source source) throws XP
320320
throw new XPathException(this, ErrorCodes.FOUT1170, e.getMessage());
321321
}
322322
if (charset == null) {
323-
charset = StandardCharsets.UTF_8;
323+
charset = UTF_8;
324324
}
325325
} else {
326326
try {

exist-core/src/main/java/org/exist/xquery/regex/RegexUtil.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,6 @@ public static String translateRegexp(final Expression context, final String patt
155155
}
156156
}
157157

158-
/**
159-
* Convert XML Schema/XPath \p{Is<Block>} and \P{Is<Block>} Unicode block
160-
* property escapes to Java's \p{In<Block>} and \P{In<Block>} syntax.
161-
*/
162-
private static String convertUnicodeBlockNames(final String pattern) {
163-
return pattern
164-
.replaceAll("\\\\p\\{Is([^}]+)}", "\\\\p{In$1}")
165-
.replaceAll("\\\\P\\{Is([^}]+)}", "\\\\P{In$1}");
166-
}
167-
168158
/**
169159
* Validates that a regex pattern only uses constructs allowed by the XPath
170160
* regular expression specification (F&amp;O 3.1, Section 5.6.1), with

0 commit comments

Comments
 (0)