Explicit initialization

MSAL

Checks if any class or object member is explicitly initialized to default for its type value:

  • null for object references
  • zero for int, long, short and char
  • and false for boolean Removes explicit initializations where they aren't necessary. Since the JVM already guarantees these defaults, restating them adds visual noise and can obscure fields that are intentionally initialized to non-default values.
org.openrewrite.staticanalysis.ExplicitInitialization
mod run . --recipe=org.openrewrite.staticanalysis.ExplicitInitialization

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