Skip to content

Commit 421ed81

Browse files
authored
Merge pull request #687 from ascopes/bugfix/nullability-annotations
Fix nullability annotations, documentation.
2 parents 947f193 + 9906e12 commit 421ed81

File tree

86 files changed

+386
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+386
-161
lines changed

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/AbstractContainerGroupAssert.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.apiguardian.api.API.Status;
2626
import org.assertj.core.api.AbstractAssert;
2727
import org.assertj.core.api.AbstractListAssert;
28-
import org.assertj.core.api.Assertions;
2928
import org.assertj.core.api.ObjectAssert;
3029
import org.jspecify.annotations.Nullable;
3130

@@ -47,6 +46,7 @@ public abstract class AbstractContainerGroupAssert<I extends AbstractContainerGr
4746
* @param containerGroup the container group to assert upon.
4847
* @param selfType the type of the assertion implementation to use.
4948
*/
49+
@SuppressWarnings("DataFlowIssue")
5050
protected AbstractContainerGroupAssert(@Nullable C containerGroup, Class<?> selfType) {
5151
super(containerGroup, selfType);
5252
}

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/AbstractEnumAssert.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public abstract class AbstractEnumAssert<A extends AbstractEnumAssert<A, E>, E e
4444
* @param value the value to assert upon.
4545
* @param selfType the type of this assertion implementation.
4646
*/
47+
@SuppressWarnings("DataFlowIssue")
4748
protected AbstractEnumAssert(@Nullable E value, Class<?> selfType) {
4849
super(value, selfType);
4950
}

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/AbstractJavaFileObjectAssert.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public abstract class AbstractJavaFileObjectAssert<I extends AbstractJavaFileObj
5454
* @param actual the actual value to assert on.
5555
* @param selfType the type of the assertion implementation.
5656
*/
57+
@SuppressWarnings("DataFlowIssue")
5758
protected AbstractJavaFileObjectAssert(@Nullable A actual, Class<?> selfType) {
5859
super(actual, selfType);
5960
}
@@ -167,10 +168,10 @@ public JavaFileObjectKindAssert kind() {
167168

168169
private byte[] rawContent() {
169170
return uncheckedIo(() -> {
170-
var baos = new ByteArrayOutputStream();
171-
try (var is = actual.openInputStream()) {
172-
is.transferTo(baos);
173-
return baos.toByteArray();
171+
var outputStream = new ByteArrayOutputStream();
172+
try (var inputStream = actual.openInputStream()) {
173+
inputStream.transferTo(outputStream);
174+
return outputStream.toByteArray();
174175
}
175176
});
176177
}

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/ClassLoaderAssert.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public final class ClassLoaderAssert extends AbstractAssert<ClassLoaderAssert, C
3737
*
3838
* @param actual the class loader to assert upon.
3939
*/
40+
@SuppressWarnings("DataFlowIssue")
4041
public ClassLoaderAssert(@Nullable ClassLoader actual) {
4142
super(actual, ClassLoaderAssert.class);
4243
}

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/JctAssertions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
* @since 0.0.1
3838
*/
3939
@API(since = "0.0.1", status = Status.STABLE)
40+
@SuppressWarnings("unused")
4041
public final class JctAssertions extends UtilityClass {
4142

4243
private JctAssertions() {
@@ -256,7 +257,7 @@ public static TraceDiagnosticAssert assertThatDiagnostic(
256257
* @return the assertion.
257258
*/
258259
public static TraceDiagnosticListAssert assertThatDiagnostics(
259-
@Nullable List<@Nullable ? extends TraceDiagnostic<? extends JavaFileObject>> diagnostics
260+
@Nullable List<? extends TraceDiagnostic<? extends JavaFileObject>> diagnostics
260261
) {
261262
return new TraceDiagnosticListAssert(diagnostics);
262263
}

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/JctCompilationAssert.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public final class JctCompilationAssert extends
5151
*
5252
* @param value the value to assert on.
5353
*/
54+
@SuppressWarnings("DataFlowIssue")
5455
public JctCompilationAssert(@Nullable JctCompilation value) {
5556
super(value, JctCompilationAssert.class);
5657
}

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/LocationAssert.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public final class LocationAssert extends AbstractAssert<LocationAssert, Locatio
3939
*
4040
* @param value the value to assert on.
4141
*/
42+
@SuppressWarnings("DataFlowIssue")
4243
public LocationAssert(@Nullable Location value) {
4344
super(value, LocationAssert.class);
4445
info.useRepresentation(LocationRepresentation.getInstance());

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/PackageContainerGroupAssert.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,17 @@ public PackageContainerGroupAssert allFilesExist(Iterable<String> paths) {
102102
}
103103
}
104104

105-
if (errors.size() >= 1) {
106-
throw new MultipleAssertionsError(
107-
new TextDescription(
108-
"Expected all paths in %s to exist but one or more did not",
109-
quotedIterable(paths)
110-
),
111-
errors
112-
);
105+
if (errors.isEmpty()) {
106+
return this;
113107
}
114108

115-
return this;
109+
throw new MultipleAssertionsError(
110+
new TextDescription(
111+
"Expected all paths in %s to exist but one or more did not",
112+
quotedIterable(paths)
113+
),
114+
errors
115+
);
116116
}
117117

118118
/**
@@ -207,6 +207,7 @@ public AbstractPathAssert<?> fileExists(String fragment, String... fragments) {
207207
this::quotedUserProvidedPath,
208208
"file with relative path"
209209
);
210+
210211
throw failure(message);
211212
}
212213

@@ -247,7 +248,7 @@ private <T> String fuzzySafePath(Iterable<T> parts) {
247248
}
248249

249250
private boolean fileNameIsPresent(@Nullable Path path) {
250-
// Path can be null if no path elements exist in ZipPath impls.
251+
// Path can be null if no path elements exist in ZipPath implementations.
251252
return Optional
252253
.ofNullable(path)
253254
.map(Path::getFileName)

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/StackTraceAssert.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public final class StackTraceAssert
4141
*
4242
* @param actual the list of stack trace elements to assert upon.
4343
*/
44+
@SuppressWarnings("DataFlowIssue")
4445
public StackTraceAssert(@Nullable List<? extends StackTraceElement> actual) {
4546
super(actual, StackTraceAssert.class);
4647
info.useRepresentation(StackTraceRepresentation.getInstance());

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/StackTraceElementAssert.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public final class StackTraceElementAssert
4343
*
4444
* @param actual the stacktrace element to assert upon.
4545
*/
46+
@SuppressWarnings("DataFlowIssue")
4647
public StackTraceElementAssert(@Nullable StackTraceElement actual) {
4748
super(actual, StackTraceElementAssert.class);
4849
}

0 commit comments

Comments
 (0)