From 6ac8d10026eecb514336849319dc8662d571566e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Schn=C3=A9ider?= Date: Tue, 16 Jul 2024 22:28:23 +0000 Subject: [PATCH] refactor: Move `@Nullable` method annotations to the return type Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.NullableOnMethodReturnType?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne --- .../java/security/PartialPathTraversalVulnerability.java | 3 +-- .../openrewrite/java/security/UseFilesCreateTempDirectory.java | 3 +-- .../java/security/marshalling/SecureSnakeYamlConstructor.java | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/openrewrite/java/security/PartialPathTraversalVulnerability.java b/src/main/java/org/openrewrite/java/security/PartialPathTraversalVulnerability.java index e8f3677..8c4b669 100644 --- a/src/main/java/org/openrewrite/java/security/PartialPathTraversalVulnerability.java +++ b/src/main/java/org/openrewrite/java/security/PartialPathTraversalVulnerability.java @@ -188,8 +188,7 @@ static class ExpressionWithTry { @Nullable J.Try maybeTryStatement; } - @Nullable - private static J.Try findNearestRelevantTry(Cursor startCursor) { + private static @Nullable J.Try findNearestRelevantTry(Cursor startCursor) { for (Cursor cursor : (Iterable) startCursor::getPathAsCursors) { Object cursorValue = cursor.getValue(); if (cursorValue instanceof J.Try) { diff --git a/src/main/java/org/openrewrite/java/security/UseFilesCreateTempDirectory.java b/src/main/java/org/openrewrite/java/security/UseFilesCreateTempDirectory.java index e482584..f43fbe2 100644 --- a/src/main/java/org/openrewrite/java/security/UseFilesCreateTempDirectory.java +++ b/src/main/java/org/openrewrite/java/security/UseFilesCreateTempDirectory.java @@ -345,8 +345,7 @@ private static boolean isMethodForIdent(J.Identifier ident, InvocationMatcher in return false; } - @Nullable - private static J.Identifier getIdent(J createFileStatement) { + private static @Nullable J.Identifier getIdent(J createFileStatement) { if (createFileStatement instanceof J.Assignment) { J.Assignment assignment = (J.Assignment) createFileStatement; return (J.Identifier) assignment.getVariable(); diff --git a/src/main/java/org/openrewrite/java/security/marshalling/SecureSnakeYamlConstructor.java b/src/main/java/org/openrewrite/java/security/marshalling/SecureSnakeYamlConstructor.java index 2e61114..c74edfd 100644 --- a/src/main/java/org/openrewrite/java/security/marshalling/SecureSnakeYamlConstructor.java +++ b/src/main/java/org/openrewrite/java/security/marshalling/SecureSnakeYamlConstructor.java @@ -236,8 +236,7 @@ private boolean isSnakeYamlType(@Nullable JavaType type) { return isUnsafe.get(); } - @Nullable - private static Cursor getOuterMostExecutableBlock(Cursor startCursor) { + private static @Nullable Cursor getOuterMostExecutableBlock(Cursor startCursor) { Cursor blockCursor = null; for (Cursor cursor : (Iterable) startCursor::getPathAsCursors) { Object cursorValue = cursor.getValue();