Skip to content

Commit d3acb4c

Browse files
committed
Get rid of useless SpotBugs suppressions
1 parent 315a088 commit d3acb4c

File tree

7 files changed

+26
-37
lines changed

7 files changed

+26
-37
lines changed

etc/assertj-templates/soft_assertions_entry_point_class_template.txt

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package ${package};
33
/**
44
* Entry point for soft assertions of different data types.
55
*/
6-
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings("NM")
76
@edu.hm.hafner.util.Generated(value="assertj-assertions-generator")
87
public class SoftAssertions extends org.assertj.core.api.AutoCloseableSoftAssertions {
98
${all_assertions_entry_points}

src/main/java/edu/hm/hafner/util/LineRangeList.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package edu.hm.hafner.util;
22

3+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
4+
5+
import edu.umd.cs.findbugs.annotations.NonNull;
6+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
7+
import edu.umd.cs.findbugs.annotations.SuppressMatchType;
8+
39
import java.io.Serial;
410
import java.io.Serializable;
511
import java.util.AbstractList;
@@ -12,11 +18,6 @@
1218
import java.util.NoSuchElementException;
1319
import java.util.stream.StreamSupport;
1420

15-
import com.google.errorprone.annotations.CanIgnoreReturnValue;
16-
17-
import edu.umd.cs.findbugs.annotations.NonNull;
18-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
19-
2021
/**
2122
* {@link List} of {@link LineRange} that stores values more efficiently at runtime.
2223
*
@@ -241,7 +242,8 @@ private void prev() {
241242
*
242243
* @return the current element
243244
*/
244-
@Override @SuppressFBWarnings(value = "IT_NO_SUCH_ELEMENT", justification = "thrown in read()")
245+
@Override
246+
@SuppressFBWarnings(value = ".*", justification = "thrown in read()", matchType = SuppressMatchType.REGEX)
245247
public LineRange next() {
246248
int s = read();
247249
int d = read();

src/main/java/edu/hm/hafner/util/SecureXmlParserFactory.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package edu.hm.hafner.util;
22

3-
import java.io.IOException;
4-
import java.io.Reader;
5-
import java.io.Serial;
6-
import java.nio.charset.Charset;
73
import javax.xml.parsers.DocumentBuilder;
84
import javax.xml.parsers.DocumentBuilderFactory;
95
import javax.xml.parsers.ParserConfigurationException;
@@ -30,6 +26,11 @@
3026

3127
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3228

29+
import java.io.IOException;
30+
import java.io.Reader;
31+
import java.io.Serial;
32+
import java.nio.charset.Charset;
33+
3334
import static javax.xml.XMLConstants.*;
3435

3536
/**
@@ -318,7 +319,6 @@ private InputSource createInputSource(final Reader reader, final Charset charset
318319
*
319320
* @return the created {@link Transformer}
320321
*/
321-
@SuppressFBWarnings(value = {"XXE_DTD_TRANSFORM_FACTORY", "XXE_XSLT_TRANSFORM_FACTORY"}, justification = "The transformer is secured in the called method")
322322
public Transformer createTransformer() {
323323
try {
324324
var transformerFactory = createTransformerFactory();

src/test/java/edu/hm/hafner/util/AbstractEqualsTest.java

-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import org.junit.jupiter.api.Test;
44

5-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
6-
75
import static org.assertj.core.api.Assertions.*;
86

97
/**
@@ -23,7 +21,6 @@ public abstract class AbstractEqualsTest {
2321
* Verifies that for any non-null reference value {@code x}, {@code x.equals(null)} should return {@code false}.
2422
*/
2523
@Test
26-
@SuppressFBWarnings("EC")
2724
@SuppressWarnings({"PMD.EqualsNull", "checkstyle:equalsavoidnull", "ConstantConditions"})
2825
void shouldReturnFalseOnEqualsNull() {
2926
assertThat(createSut().equals(null)).isFalse();

src/test/java/edu/hm/hafner/util/PathUtilTest.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package edu.hm.hafner.util;
22

3-
import java.io.IOException;
4-
import java.nio.file.LinkOption;
5-
import java.nio.file.Path;
6-
73
import org.junit.jupiter.api.DisplayName;
84
import org.junit.jupiter.api.Test;
95
import org.junit.jupiter.params.ParameterizedTest;
106
import org.junit.jupiter.params.provider.ValueSource;
117

12-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
8+
import java.io.IOException;
9+
import java.nio.file.LinkOption;
10+
import java.nio.file.Path;
1311

1412
import static org.assertj.core.api.Assertions.*;
1513
import static org.assertj.core.api.Assumptions.*;
@@ -19,7 +17,6 @@
1917
*
2018
* @author Ullrich Hafner
2119
*/
22-
@SuppressFBWarnings("DMI")
2320
@SuppressWarnings("NullAway") // in tests, we do not care about null values when the path does not exist
2421
class PathUtilTest extends ResourceTest {
2522
private static final String NOT_EXISTING = "/should/not/exist";

src/test/java/edu/hm/hafner/util/ResourceTest.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package edu.hm.hafner.util;
22

3+
import org.apache.commons.io.IOUtils;
4+
import org.apache.commons.io.input.BOMInputStream;
5+
import org.opentest4j.TestAbortedException;
6+
7+
import com.google.errorprone.annotations.MustBeClosed;
8+
39
import java.io.BufferedReader;
410
import java.io.File;
511
import java.io.IOException;
@@ -12,14 +18,6 @@
1218
import java.nio.file.Path;
1319
import java.util.stream.Stream;
1420

15-
import org.apache.commons.io.IOUtils;
16-
import org.apache.commons.io.input.BOMInputStream;
17-
import org.opentest4j.TestAbortedException;
18-
19-
import com.google.errorprone.annotations.MustBeClosed;
20-
21-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
22-
2321
import static org.assertj.core.api.Assumptions.*;
2422

2523
/**
@@ -105,7 +103,6 @@ protected byte[] readAllBytes(final Path path) {
105103
}
106104
}
107105

108-
@SuppressFBWarnings("UI_INHERITANCE_UNSAFE_GETRESOURCE")
109106
private Path getPath(final String name) throws URISyntaxException {
110107
var resource = getTestResourceClass().getResource(name);
111108
ensureThatResourceExists(resource, name);

src/test/java/edu/hm/hafner/util/SerializableTest.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package edu.hm.hafner.util;
22

3+
import org.assertj.core.api.ObjectAssert;
4+
import org.junit.jupiter.api.DisplayName;
5+
import org.junit.jupiter.api.Test;
6+
37
import java.io.ByteArrayInputStream;
48
import java.io.ByteArrayOutputStream;
59
import java.io.IOException;
@@ -10,12 +14,6 @@
1014
import java.nio.file.Path;
1115
import java.nio.file.StandardOpenOption;
1216

13-
import org.assertj.core.api.ObjectAssert;
14-
import org.junit.jupiter.api.DisplayName;
15-
import org.junit.jupiter.api.Test;
16-
17-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
18-
1917
import static org.assertj.core.api.Assertions.*;
2018

2119
/**
@@ -121,7 +119,6 @@ protected byte[] toByteArray(final Serializable object) {
121119
* @throws IOException
122120
* if the file could not be created
123121
*/
124-
@SuppressFBWarnings("DMI")
125122
protected void createSerializationFile() throws IOException {
126123
Files.write(Path.of("/tmp/serializable.ser"), toByteArray(createSerializable()),
127124
StandardOpenOption.CREATE_NEW);

0 commit comments

Comments
 (0)