You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description = "The fully qualified name of the @Nullable annotation. The annotation should be meta annotated with `@Target(TYPE_USE)`. Defaults to `org.jspecify.annotations.Nullable`",
@@ -58,19 +46,28 @@ public class AnnotateNullableParameters extends Recipe {
58
46
@Nullable
59
47
StringnullableAnnotationClass;
60
48
49
+
@Option(
50
+
displayName = "Additional null-checking methods",
51
+
description = "A list of method patterns (in OpenRewrite MethodMatcher format) that should be considered as null-checking methods. " +
52
+
"These will be added to the built-in list of known null-checking methods. " +
53
+
"Use `..` for any parameters, e.g., `com.mycompany.utils.StringUtil isEmpty(..)` or `com.mycompany.utils.CollectionUtil isNullOrEmpty(java.util.Collection)`",
54
+
example = "com.mycompany.utils.StringUtil isEmpty(..), com.mycompany.utils.CollectionUtil isNullOrEmpty(..)",
55
+
required = false)
56
+
@Nullable
57
+
List<String> additionalNullCheckingMethods;
58
+
61
59
@Override
62
60
publicStringgetDisplayName() {
63
61
return"Annotate null-checked method parameters with `@Nullable`";
64
62
}
65
63
66
64
@Override
67
65
publicStringgetDescription() {
68
-
69
-
return"Add `@Nullable` to parameters of public methods that are explicitly checked for `null`. " +
70
-
"By default `org.jspecify.annotations.Nullable` is used, but through the `nullableAnnotationClass` option a custom annotation can be provided. " +
71
-
"When providing a custom `nullableAnnotationClass` that annotation should be meta annotated with `@Target(TYPE_USE)`. " +
72
-
"This recipe scans for methods that do not already have parameters annotated with `@Nullable` annotation and checks their usages " +
73
-
"for potential null checks.";
66
+
return"Add `@Nullable` to parameters of public methods that are explicitly checked for `null`. "
67
+
+ "By default `org.jspecify.annotations.Nullable` is used, but through the `nullableAnnotationClass` option a custom annotation can be provided. "
68
+
+ "When providing a custom `nullableAnnotationClass` that annotation should be meta annotated with `@Target(TYPE_USE)`. "
69
+
+ "This recipe scans for methods that do not already have parameters annotated with `@Nullable` annotation and checks their usages "
70
+
+ "for potential null checks. Additional null-checking methods can be specified via the `additionalNullCheckingMethods` option.";
74
71
}
75
72
76
73
@Override
@@ -100,7 +97,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration methodDecl
0 commit comments