Find casts that always fail

Proprietary

Marks a cast that throws a ClassCastException: a cast of a value whose class is known, because it was created with new or is a literal, either directly or through a local variable or final field that is never reassigned, to a type that class is not. Also marks a cast of a variable to a type where an instanceof check has just shown the variable is not of that type, inside the branch the check rules out or after an if on it that always returns, throws, breaks or continues, which fails unless the variable is null. Test sources are not searched.

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

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