Skip to content

Commit 280257a

Browse files
committed
[refactor] static code analysis fixes
1 parent 722c597 commit 280257a

File tree

6 files changed

+13
-18
lines changed

6 files changed

+13
-18
lines changed

exist-core/src/main/java/org/exist/validation/ValidationReport.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.io.PrintStream;
3030
import java.util.ArrayList;
3131
import java.util.List;
32-
import java.util.stream.Collectors;
3332

3433
import static java.nio.charset.StandardCharsets.UTF_8;
3534

@@ -150,7 +149,7 @@ public List<String> getTextValidationReport() {
150149
textReport.add("Exception: " + throwed.getMessage());
151150
}
152151

153-
textReport.addAll(validationReport.stream().map(ValidationReportItem::toString).collect(Collectors.toList()));
152+
textReport.addAll(validationReport.stream().map(ValidationReportItem::toString).toList());
154153

155154
textReport.add("Validated in " + duration + " millisec.");
156155
return textReport;
@@ -218,7 +217,7 @@ public String getStackTrace() {
218217
return null;
219218
}
220219

221-
final UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream();
220+
final UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
222221
final PrintStream ps = new PrintStream(baos);
223222
throwed.printStackTrace(ps);
224223
return baos.toString(UTF_8);

exist-core/src/main/java/org/exist/validation/ValidationReportItem.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,12 @@ public void setSystemId(final String systemId) {
8888

8989
public String getTypeText() {
9090

91-
final String reportType = switch (type) {
91+
return switch (type) {
9292
case WARNING -> "Warning";
9393
case ERROR -> "Error";
9494
case FATAL -> "Fatal";
9595
default -> "Unknown Error type";
9696
};
97-
98-
return reportType;
9997
}
10098

10199
public String toString() {

exist-core/src/main/java/org/exist/validation/Validator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import java.io.IOException;
5050
import java.io.InputStream;
5151
import java.net.URISyntaxException;
52-
import java.util.Arrays;
5352
import java.util.List;
5453
import java.util.Optional;
5554

exist-core/src/main/java/org/exist/validation/XmlLibraryChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public static void check() {
208208
public static boolean hasValidClassVersion(final String type,
209209
final ClassVersion[] validClasses, final StringBuilder message) {
210210

211-
final String sep = System.getProperty("line.separator");
211+
final String sep = System.lineSeparator();
212212

213213
message.append("Looking for a valid ").append(type).append("...").append(sep);
214214

exist-core/src/main/java/org/exist/validation/resolver/SearchResourceResolver.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import java.io.StringWriter;
5656
import java.net.URI;
5757
import java.net.URISyntaxException;
58-
import java.util.Arrays;
5958
import java.util.List;
6059
import java.util.Optional;
6160
import java.util.Properties;
@@ -82,7 +81,7 @@ public SearchResourceResolver(final BrokerPool brokerPool, final Subject subject
8281
this.collectionPath = collectionPath;
8382

8483
if (LOG.isDebugEnabled()) {
85-
LOG.debug("Specified collectionPath=" + collectionPath);
84+
LOG.debug("Specified collectionPath={}", collectionPath);
8685
}
8786
}
8887

@@ -95,7 +94,7 @@ public XMLInputSource resolveEntity(final XMLResourceIdentifier xri) throws XNIE
9594
}
9695

9796
if (LOG.isDebugEnabled()) {
98-
LOG.debug("Resolving XMLResourceIdentifier: " + getXriDetails(xri));
97+
LOG.debug("Resolving XMLResourceIdentifier: {}", getXriDetails(xri));
9998
}
10099

101100

@@ -105,20 +104,20 @@ public XMLInputSource resolveEntity(final XMLResourceIdentifier xri) throws XNIE
105104
if (xri.getNamespace() != null) {
106105
// XML Schema search
107106
if (LOG.isDebugEnabled()) {
108-
LOG.debug("Searching namespace '" + xri.getNamespace() + "' in database from " + collectionPath + "...");
107+
LOG.debug("Searching namespace '{}' in database from {}...", xri.getNamespace(), collectionPath);
109108
}
110109

111110
resourcePath = databaseResources.findXSD(collectionPath, xri.getNamespace(), subject);
112111

113112
} else if (xri.getPublicId() != null) {
114113
// Catalog search
115114
if (LOG.isDebugEnabled()) {
116-
LOG.debug("Searching publicId '" + xri.getPublicId() + "' in catalogs in database from " + collectionPath + "...");
115+
LOG.debug("Searching publicId '{}' in catalogs in database from {}...", xri.getPublicId(), collectionPath);
117116
}
118117

119118
String catalogPath = databaseResources.findCatalogWithDTD(collectionPath, xri.getPublicId(), subject);
120119
if (LOG.isDebugEnabled()) {
121-
LOG.debug("Found publicId in catalog '" + catalogPath + "'");
120+
LOG.debug("Found publicId in catalog '{}'", catalogPath);
122121
}
123122

124123
if (catalogPath != null) {
@@ -169,15 +168,15 @@ public XMLInputSource resolveEntity(final XMLResourceIdentifier xri) throws XNIE
169168
resourcePath = ResolverFactory.fixupExistCatalogUri(resourcePath);
170169

171170
if (LOG.isDebugEnabled()) {
172-
LOG.debug("resourcePath='" + resourcePath + "'");
171+
LOG.debug("resourcePath='{}'", resourcePath);
173172
}
174173

175174
final InputStream is = URI.create(resourcePath).toURL().openStream();
176175

177176
final XMLInputSource xis = new XMLInputSource(xri.getPublicId(), xri.getExpandedSystemId(), xri.getBaseSystemId(), is, UTF_8.name());
178177

179178
if (LOG.isDebugEnabled()) {
180-
LOG.debug("XMLInputSource: " + getXisDetails(xis));
179+
LOG.debug("XMLInputSource: {}", getXisDetails(xis));
181180
}
182181

183182
return xis;

exist-core/src/main/java/org/exist/validation/resolver/unstable/ExistResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public Source resolve(String href, String base) throws TransformerException {
111111
/* ============== */
112112
private InputSource resolveInputSource(final BrokerPool bPool, final String path) throws IOException {
113113

114-
LOG.debug("Resolving {}", path);
114+
LOG.debug("Resolving inputSource {}", path);
115115

116116
final InputSource inputsource = new InputSource();
117117

@@ -134,7 +134,7 @@ private InputSource resolveInputSource(final BrokerPool bPool, final String path
134134

135135
private StreamSource resolveStreamSource(final BrokerPool bPool, final String path) throws TransformerException {
136136

137-
LOG.debug("Resolving {}", path);
137+
LOG.debug("Resolving streamSource {}", path);
138138

139139
final StreamSource streamsource = new StreamSource();
140140

0 commit comments

Comments
 (0)