squid:S3655 (Optional use without isPresent) should not fire if .isEmpty() was called

We’re using Version 7.3 (build 15553) of SonarQube, and squid:S3655 fires a lot when people replace

if (!optional.isPresent()) {
    return;
}

with

if (optional.isEmpty()) {
    return;
}

The latter is the cleaner version available since Java 11.

It would be great if S3655 could be updated to accept optional.isEmpty() as an alias for !optional.isPresent().

15 Likes

I have the same problem. Is there an adjustment deadline?

hello @ArneBab ,

thanks for reporting this issue, and sorry for the delay. I created the ticket to update rule implementation https://jira.sonarsource.com/browse/SONARJAVA-3087 .

@JanioSamuel there is no deadline, however we try to fix such issues rather quickly, I expect it to be fixed within 1 - 2 months.