squid:S3655 False Positive on if + &&

This is the compliant solution

Optional<String> value = this.getOptionalValue();    
if (value.isPresent()) {    String stringValue = value.get();  }

This is my code

Optional<String> value1 = this.getOptionalValue1();    
Optional<String> value2 = this.getOptionalValue2();    
if ((value1.isPresent()) && (value2.isPresent())) {
    func(value1.get(), value2.get());

This throws the warning, which looks like a False Positive to me

java8 with sonar 7.3 with sonar-java

Are you sure of the version of SonarJava ? this version is more than 2 years old. I would recommend to upgrade to latest version (sonarjava ) and let us know if the problem persists.

Hi, I’m sorry the version of sonar java is actually, I edited the post to fix it, thanks :slight_smile:

still looks like a False Positive to me, can you guys reproduce this? It should be fairly quick to test it out


I can’t reproduce your problem. Are you sure you provided all required details in your code snippet?