Add a null method argument

Apache 2.0

Add a null argument to method invocations.

org.openrewrite.java.AddNullMethodArgument

Required

A method pattern is used to find matching method invocations. For example, to find all method invocations in the Guava library, use the pattern: com.google.common..*#*(..).

The pattern format is <PACKAGE>#<METHOD_NAME>(<ARGS>).

..* includes all subpackages of com.google.common.
*(..) matches any method name with any number of arguments.

For more specific queries, like Guava's ImmutableMap, use com.google.common.collect.ImmutableMap#*(..) to narrow down the results.

A zero-based index that indicates which argument will be added as null to the method invocation.

The type of the parameter that we add the argument for.

Optional

The name of the parameter that we add the argument for.

explicitCastBoolean

Explicitly cast the argument to the parameter type. Useful if the method is overridden with another type.

mod run . --recipe=org.openrewrite.java.AddNullMethodArgument \ -P methodPattern='com.yourorg.A foo(int, int)' \ -P argumentIndex=0 \ -P parameterType=java.lang.String

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.