UTAO false positive with complex boolean expression
I have a unit test to ensure that a utility class is properly defined (private constructor, all methods static, etc), and one of the assertions is triggering UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_EQUALS, but I don't see another (let alone a better) way to structure it.
The assertion looks like:
for (final Method method : clazz.getMethods()) {
assertTrue("method should be static:" + method,
Modifier.isStatic(method.getModifiers()) || !method.getDeclaringClass().equals(clazz));
}
i added the above, but unfortunately it didn't fire the FP. See anything i screwed up?
No, I can't see anything wrong with the sample, but the detector is still firing for me. I've tried altering my compiler configuration (switched between JDK7 and 8, toggled debug and optimise flags on and off); no change. I also tried increasing my threshold to Default, but it still fired.
I'm still seeing this - including for an exact copy of the code in the sample GitHubIssue207 class - with version 7.4.0.sb.
I'm not enough of an expert to read this properly, but it looks like UnitTestAssertionOddities will only record this bug when it thinks it has seen a negated equals expression. This occurs as part of the sample code, !method.getDeclaringClass().equals(clazz), but since this is only one part of the expression, it shouldn't fire.