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