Find new exceptions thrown without the caught exception

MSAL

Finds catch blocks that throw a newly created exception without referencing the caught exception, which discards the original exception's stack trace and message. Taint tracking over the local variables of the catch block establishes whether the caught exception—or any value derived from it—reaches the thrown exception, so indirect references through local variables, helper calls and string concatenation are not falsely reported. This mirrors PMD's PreserveStackTrace rule.

org.openrewrite.staticanalysis.FindNewExceptionWithoutCause
mod run . --recipe=org.openrewrite.staticanalysis.FindNewExceptionWithoutCause

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