Replace reverse iteration with a reversed view

Proprietary

Replaces loops that walk a java.util.List backwards, by index or with listIterator(size()), with an enhanced for over its reversed() view, in main sources on Java 21 or later. Skips lists of non-JDK types, an index used other than in get, an indexed loop whose body calls non-JDK code or writes to the list or a possible alias, and an iterator used other than by one previous() that the body takes first.

io.moderne.staticanalysis.ReplaceReverseIterationWithReversedView
mod run . --recipe=io.moderne.staticanalysis.ReplaceReverseIterationWithReversedView

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