Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTAO false positive with complex boolean expression #207

Open
ThrawnCA opened this issue Jun 22, 2017 · 4 comments
Open

UTAO false positive with complex boolean expression #207

ThrawnCA opened this issue Jun 22, 2017 · 4 comments

Comments

@ThrawnCA
Copy link
Contributor

ThrawnCA commented Jun 22, 2017

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));
    }
mebigfatguy added a commit that referenced this issue Jun 22, 2017
@mebigfatguy
Copy link
Owner

i added the above, but unfortunately it didn't fire the FP. See anything i screwed up?

@ThrawnCA
Copy link
Contributor Author

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.

@ThrawnCA
Copy link
Contributor Author

ThrawnCA commented Jun 1, 2018

I'm still seeing this - including for an exact copy of the code in the sample GitHubIssue207 class - with version 7.4.0.sb.

@ThrawnCA
Copy link
Contributor Author

ThrawnCA commented Jun 1, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants