Replace nullable x.toString() with String.valueOf(x)
ProprietaryRewrites x.toString() to String.valueOf(x) when the receiver x is provably nullable at that site. x.toString() dereferences x and throws NullPointerException when x is null, which NullAway flags inside an annotated scope; String.valueOf(x) returns the string "null" instead. This is a behavior change on the null path (NullPointerException becomes the string "null"), so every rewritten call is marked for review — it is not behavior-preserving. Only the no-arg toString() whose receiver is a reference value is rewritten; a primitive receiver, a type or package qualifier, a .class literal, and this/super are never touched, and a receiver already asserted non-null is skipped. The receiver's nullness is resolved by attribution from the nullability model and a path-sensitive flow analysis (a value already null-checked on the path is not flagged). The fix never rewrites a call whose receiver is genuinely non-null at the site. Conservative; only Java sources are modified.
io. moderne. nullability. ReplaceNullableToStringWithStringValueOfOptional
Comma-separated package prefixes to limit the fix to (matching NullAway's AnnotatedPackages option). When unset, the recipe fixes all packages.
mod run . --recipe= io. moderne. nullability. ReplaceNullableToStringWithStringValueOfInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.