A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/3087 below:

[java] UnnecessaryBooleanAssertion overlaps with SimplifiableTestAssertion · Issue #3087 · pmd/pmd · GitHub

Affects PMD Version: 6.30

Rule: UnnecessaryBooleanAssertion
https://pmd.github.io/pmd-6.30.0/pmd_rules_java_errorprone.html#unnecessarybooleanassertion

Description: There is a problem when the boolean value is used with ! after a function call to test the function.
Please, check this case.

Thank you.

Code Sample demonstrating the issue:

import org.junit.Assert;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

class TestUnnecessaryBooleanAssertion {
        @Test
        public void testPMD(){
                test(foo);
        }

        protected void test(Foo foo) {
                boolean testResult = testFunction(foo);

                assertTrue(!testResult);    //an alarm is generated
                assertTrue(testResult);    //an alarm isn't generated
    }
}

Expected outcome:
Don't show any alarms.

Running PMD through: [CLI]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4