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

versions:
java8 with sonar 7.3 with sonar-java 5.12.1.17771

Hi,
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 5.13.1.18282 ) and let us know if the problem persists.

Hi, I’m sorry the version of sonar java is actually 5.12.1.17771, 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