Find assertions comparing incompatible types

Proprietary

Marks JUnit 4 and JUnit 5 assertNull/assertNotNull calls and AssertJ isNull()/isNotNull() checks on a primitive value, and marks the expected argument of assertEquals/assertNotEquals and of AssertJ isEqualTo, isNotEqualTo, isSameAs and isNotSameAs when the two compared values can never be equal: null against a primitive, an array against a non-array other than Object, Serializable and Cloneable, arrays with incompatible element types, or unrelated classes. A type variable or wildcard is compared as its bound, and skipped when it has several. A positive assertion between a class and an unrelated interface is only marked when the class is final, a record, or an enum without constant bodies. Skipped: comparisons where a type or one of its supertypes is unresolved, other than an array of an unresolved type against a non-array, overloads that take the expected value as a primitive, assertNotEquals/isNotEqualTo inside a method whose name mentions equal, hashCode, toString or objectMethod, AssertJ date, temporal, BigInteger and BigDecimal assertions, which accept a String, and assertThat(AssertProvider), whose assertion is the provider's own.

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

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