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]
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:
Expected outcome:
Don't show any alarms.
Running PMD through: [CLI]