Find visitor instances shared across getVisitor() calls

MSAL

Find static fields, and instance fields of Recipe classes, holding TreeVisitor instances. getVisitor() is called once per source file and source files may be visited concurrently, so a shared visitor that walks the tree has its cursor, visit count and after-visit list corrupted by concurrent visits. Construct such visitors inside getVisitor() instead. Fields holding only visitors which keep no per-visit state, such as UsesType combined through Preconditions.or/and/not, are not reported.

org.openrewrite.java.recipes.FindSharedVisitorInstances
mod run . --recipe=org.openrewrite.java.recipes.FindSharedVisitorInstances

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