Skip to content

Commit 4681003

Browse files
committed
bug(#301): up qulice, fix warnings
1 parent e143ecd commit 4681003

25 files changed

Lines changed: 121 additions & 91 deletions

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
<plugin>
204204
<groupId>com.qulice</groupId>
205205
<artifactId>qulice-maven-plugin</artifactId>
206-
<version>0.22.0</version>
206+
<version>0.24.0</version>
207207
<configuration>
208208
<excludes combine.children="append">
209209
<exclude>xml:/src/it/settings.xml</exclude>

src/main/java/com/jcabi/xml/ClasspathInput.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public String getEncoding() {
8484
return null;
8585
}
8686

87+
@SuppressWarnings("PMD.AvoidCatchingGenericException")
8788
@Override
8889
public String getStringData() {
8990
try {

src/main/java/com/jcabi/xml/ClasspathSources.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,25 @@ public ClasspathSources(final String pfx) {
5656
}
5757

5858
@Override
59+
@SuppressWarnings("PMD.CloseResource")
5960
public Source resolve(final String href, final String base)
6061
throws TransformerException {
6162
InputStream stream = this.getClass().getResourceAsStream(
6263
String.format(ClasspathSources.PATTERN, this.prefix, href)
6364
);
6465
if (stream == null) {
65-
stream = this.getClass().getResourceAsStream(
66+
final InputStream fallback = this.getClass().getResourceAsStream(
6667
String.format(ClasspathSources.PATTERN, base, href)
6768
);
68-
if (stream == null) {
69+
if (fallback == null) {
6970
throw new TransformerException(
7071
String.format(
7172
"Resource \"%s\" not found in classpath with prefix \"%s\" and base \"%s\"",
7273
href, this.prefix, base
7374
)
7475
);
7576
}
77+
stream = fallback;
7678
}
7779
return new StreamSource(stream);
7880
}

src/main/java/com/jcabi/xml/DomParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ private DomParser(final DocumentBuilderFactory factory, final DocSource source)
100100
* Get the document body.
101101
* @return The document
102102
*/
103+
@SuppressWarnings("PMD.PrematureDeclaration")
103104
public Document document() {
104105
final DocumentBuilder builder;
105106
try {
@@ -213,6 +214,7 @@ private static class BytesSource implements DocSource {
213214
* Public ctor.
214215
* @param xml Bytes of the XML.
215216
*/
217+
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
216218
BytesSource(final byte[] xml) {
217219
this.xml = xml;
218220
}

src/main/java/com/jcabi/xml/FileSources.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
package com.jcabi.xml;
66

77
import java.io.File;
8-
import java.io.FileInputStream;
9-
import java.io.FileNotFoundException;
108
import java.io.IOException;
119
import java.nio.file.Files;
1210
import javax.xml.transform.Source;

src/main/java/com/jcabi/xml/ListWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
/**
1515
* Wrapper of {@link List}.
16+
* @param <T> Time of items
1617
*
1718
* <p>This wrapper is our internal implementation of a {@link List}. The only
1819
* purpose of this wrapper is to throw our own custom exception when the client
@@ -54,7 +55,6 @@
5455
* <p>The class is immutable and thread-safe.
5556
*
5657
* @since 0.1
57-
* @param <T> Time of items
5858
*/
5959
@SuppressWarnings("PMD.TooManyMethods")
6060
final class ListWrapper<T> implements List<T> {

src/main/java/com/jcabi/xml/SaxonDocument.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ public XML merge(final NamespaceContext context) {
179179
/**
180180
* Retrieve DOM node, represented by this wrapper.
181181
* This method works exactly the same as {@link #deepCopy()}.
182-
* @deprecated Use {@link #inner()} or {@link #deepCopy()} instead.
183182
* @return Deep copy of the inner DOM node.
183+
* @deprecated Use {@link #inner()} or {@link #deepCopy()} instead.
184184
*/
185185
@Deprecated
186186
public Node node() {

src/main/java/com/jcabi/xml/Sources.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public interface Sources extends URIResolver {
1717
/**
1818
* Dummy sources.
1919
*/
20+
@SuppressWarnings("PMD.ConstantsInInterface")
2021
Sources DUMMY = (href, base) -> {
2122
throw new UnsupportedOperationException(
2223
String.format(

src/main/java/com/jcabi/xml/StrictXML.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* @since 0.7
2929
* @checkstyle AbbreviationAsWordInNameCheck (5 lines)
3030
*/
31+
@SuppressWarnings("PMD.TooManyMethods")
3132
@EqualsAndHashCode(of = "origin")
3233
public final class StrictXML implements XML {
3334

@@ -132,10 +133,12 @@ public XML merge(final NamespaceContext context) {
132133
/**
133134
* Retrieve DOM node, represented by this wrapper.
134135
* This method works exactly the same as {@link #deepCopy()}.
135-
* @deprecated Use {@link #inner()} or {@link #deepCopy()} instead.
136136
* @return Deep copy of the inner DOM node.
137+
* @deprecated Use {@link #inner()} or {@link #deepCopy()} instead.
138+
* @checkstyle NoJavadocForOverriddenMethodsCheck (5 lines)
137139
*/
138140
@Deprecated
141+
@Override
139142
public Node node() {
140143
return this.origin.value().deepCopy();
141144
}

src/main/java/com/jcabi/xml/TextResource.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
import java.io.BufferedInputStream;
88
import java.io.File;
9-
import java.io.FileInputStream;
109
import java.io.FileNotFoundException;
1110
import java.io.IOException;
1211
import java.io.InputStream;
1312
import java.net.URI;
1413
import java.net.URL;
1514
import java.nio.charset.StandardCharsets;
15+
import java.nio.file.Files;
1616
import java.util.Scanner;
1717
import lombok.EqualsAndHashCode;
1818

@@ -56,10 +56,10 @@ private TextResource(final String text) {
5656
* @param file File to represent as text.
5757
* @throws FileNotFoundException If file not found
5858
*/
59-
TextResource(final File file) throws FileNotFoundException {
59+
TextResource(final File file) throws IOException {
6060
this(
6161
TextResource.readAsString(
62-
new BufferedInputStream(new FileInputStream(file))
62+
new BufferedInputStream(Files.newInputStream(file.toPath()))
6363
)
6464
);
6565
}
@@ -93,18 +93,15 @@ public String toString() {
9393
* @return The stream content, in String form
9494
*/
9595
private static String readAsString(final InputStream stream) {
96-
final Scanner scanner = new Scanner(
97-
stream, StandardCharsets.UTF_8.name()
98-
).useDelimiter("\\A");
9996
final String result;
100-
try {
97+
try (Scanner scanner = new Scanner(
98+
stream, StandardCharsets.UTF_8.name()
99+
).useDelimiter("\\A")) {
101100
if (scanner.hasNext()) {
102101
result = scanner.next();
103102
} else {
104103
result = "";
105104
}
106-
} finally {
107-
scanner.close();
108105
}
109106
return result;
110107
}

0 commit comments

Comments
 (0)