diff --git a/build.gradle b/build.gradle index 464ce00a..d91b1454 100644 --- a/build.gradle +++ b/build.gradle @@ -19,6 +19,7 @@ dependencies { implementation(libs.telegram.bot.api) implementation(libs.tika) + testCompileOnly(libs.jspecify) testImplementation(libs.hamcrest) testImplementation(libs.junit.jupiter) testImplementation(libs.mockwebserver) @@ -53,6 +54,15 @@ def jlink = tasks.register('jlink', JlinkTask) { description = 'Generates a minimal JRE for the project.' } +nullability { + errorProneVersion = libs.errorprone.get().version + nullAwayVersion = libs.nullaway.get().version +} + +tasks.named("compileTestJava") { + options.nullability.checking = "tests" +} + test { inputs.dir(jlink.map { it.outputDirectory.get().asFile }) javaLauncher = providers.provider { new JlinkJavaLauncher(jlink.get()) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 66bade20..a99f040f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,4 +1,5 @@ [libraries] +errorprone = "com.google.errorprone:error_prone_core:2.42.0" gson = "com.google.code.gson:gson:2.13.2" hamcrest = "org.hamcrest:hamcrest:3.0" jspecify = "org.jspecify:jspecify:1.0.0" @@ -6,8 +7,9 @@ junit-jupiter = "org.junit.jupiter:junit-jupiter:5.14.0" junit-platform = "org.junit.platform:junit-platform-launcher:1.14.0" logback-classic = "ch.qos.logback:logback-classic:1.5.18" mockwebserver = "com.squareup.okhttp3:mockwebserver3-junit5:5.1.0" +nullaway = "com.uber.nullaway:nullaway:0.12.10" telegram-bot-api = "com.github.pengrad:java-telegram-bot-api:9.2.0" tika = "org.apache.tika:tika-core:3.2.3" [plugins] -spring-nullability = "io.spring.nullability:0.0.4" +spring-nullability = "io.spring.nullability:0.0.5" diff --git a/src/test/java/com/github/stickerifier/stickerify/logger/LoggingEvent.java b/src/test/java/com/github/stickerifier/stickerify/logger/LoggingEvent.java index 4663708e..250943cd 100644 --- a/src/test/java/com/github/stickerifier/stickerify/logger/LoggingEvent.java +++ b/src/test/java/com/github/stickerifier/stickerify/logger/LoggingEvent.java @@ -6,6 +6,7 @@ import ch.qos.logback.classic.spi.StackTraceElementProxy; import ch.qos.logback.classic.spi.ThrowableProxyVO; import com.github.stickerifier.stickerify.exception.TelegramApiException; +import org.jspecify.annotations.Nullable; /** * Test double that serves as an implementation of {@link ILoggingEvent}. @@ -15,7 +16,7 @@ class LoggingEvent extends LoggingEventVO { static final String EXCEPTION_CLASS = TelegramApiException.class.getName(); private final String formattedMessage; - private IThrowableProxy throwableProxy; + private @Nullable IThrowableProxy throwableProxy; LoggingEvent(String formattedMessage) { this.formattedMessage = formattedMessage; @@ -54,6 +55,7 @@ public String getFormattedMessage() { return formattedMessage; } + @Nullable @Override public IThrowableProxy getThrowableProxy() { return throwableProxy; diff --git a/src/test/java/com/github/stickerifier/stickerify/media/MediaHelperTest.java b/src/test/java/com/github/stickerifier/stickerify/media/MediaHelperTest.java index e09afc86..5aa342aa 100644 --- a/src/test/java/com/github/stickerifier/stickerify/media/MediaHelperTest.java +++ b/src/test/java/com/github/stickerifier/stickerify/media/MediaHelperTest.java @@ -21,6 +21,7 @@ import com.github.stickerifier.stickerify.junit.ClearTempFiles; import com.github.stickerifier.stickerify.junit.Tags; import com.github.stickerifier.stickerify.process.ProcessHelper; +import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Tag; @@ -45,7 +46,9 @@ void resizeRectangularImage() throws Exception { assertImageConsistency(result, 512, 341); } - private static void assertImageConsistency(File image, int expectedWidth, int expectedHeight) throws Exception { + private static void assertImageConsistency(@Nullable File image, int expectedWidth, int expectedHeight) throws Exception { + assertNotNull(image); + var mediaInfo = MediaHelper.retrieveMultimediaInfo(image); var imageInfo = mediaInfo.video(); assertNotNull(imageInfo); @@ -154,7 +157,9 @@ void convertLongMovVideo() throws Exception { assertVideoConsistency(result, 512, 288, 29.97003F, 2.969F); } - private static void assertVideoConsistency(File video, int expectedWidth, int expectedHeight, float expectedFrameRate, float expectedDuration) throws Exception { + private static void assertVideoConsistency(@Nullable File video, int expectedWidth, int expectedHeight, float expectedFrameRate, float expectedDuration) throws Exception { + assertNotNull(video); + var mediaInfo = MediaHelper.retrieveMultimediaInfo(video); var videoInfo = mediaInfo.video(); assertNotNull(videoInfo);