You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] SimplifiableTestAssertion: False negatives for assertInstanceOf, assertNull, assertNonNull #7119
assertTrue(ainstanceofA); // violationassertInstanceOf(a, A.class); // goodassertEquals(null, a); // violationassertNull(a); // goodassertNotEquals(null, a); // violationassertNonNull(a); // goodassertEquals(true, false); // violation, same for any two different compile time constantsfail("message"); // good
@adangel thanks, I updated the description as an amendment to the existing rule, only listing the cases that are not covered yet.
Also, if someone works on that rule, it might be worth checking that the argument indices are selected correctly (the rule seems to expect that the last two arguments of assertEquals are actual and expected in some order, but that's not true for Assertions.assertEquals(expected, actual, message)).
@zbynek Thank you for creating this ticket! In the Apache NIFI code base, we had replaced all assertTrue(a instanceof A); withassertInstanceOf(a, A.class); yet it got introduced again with a later PR. Having this in PMD would help with regression.
changed the title [-][java] add more cases to SimplifiableTestAssertion[/-][+][java] SimplifiableTestAssertion: Various false negatives[/+]on Oct 22, 2026
changed the title [-][java] SimplifiableTestAssertion: Various false negatives[/-][+][java] SimplifiableTestAssertion: False negatives for assertInstanceOf, assertNull, assertNonNull[/+]on Oct 29, 2026
Activity
pzygielo commentedon Sep 28, 2026
[-][java] new rule: SimplifieableAssertion[/-][+][java] new rule: SimplifiableAssertion[/+]adangel commentedon Sep 28, 2026
[-][java] new rule: SimplifiableAssertion[/-][+][java] add more cases to SimplifiableAssertion[/+][-][java] add more cases to SimplifiableAssertion[/-][+][java] add more cases to SimplifiableTestAssertion[/+]zbynek commentedon Sep 28, 2026
@adangel thanks, I updated the description as an amendment to the existing rule, only listing the cases that are not covered yet.
Also, if someone works on that rule, it might be worth checking that the argument indices are selected correctly (the rule seems to expect that the last two arguments of assertEquals are
actualandexpectedin some order, but that's not true forAssertions.assertEquals(expected, actual, message)).dan-s1 commentedon Oct 22, 2026
@zbynek Thank you for creating this ticket! In the Apache NIFI code base, we had replaced all
assertTrue(a instanceof A);withassertInstanceOf(a, A.class);yet it got introduced again with a later PR. Having this in PMD would help with regression.[-][java] add more cases to SimplifiableTestAssertion[/-][+][java] SimplifiableTestAssertion: Various false negatives[/+]Update release notes (pmd#7119)
[java] Fix #7119: SimplifiableTestAssertion: Report more cases (#7129)
[-][java] SimplifiableTestAssertion: Various false negatives[/-][+][java] SimplifiableTestAssertion: False negatives for assertInstanceOf, assertNull, assertNonNull[/+]