Thank you for feedback.
Indeed, it seems to be a wrong behavior of the rule.
There is a known FP related to optional when filtering is involved. This problem has been addressed in ticket SONARJAVA-2873 and will be fixed in the next sonar-java version.
I will investigate further the changes in behavior depending on the cases you mentioned, it seems to be another problem altogether.
There is indeed another issue regarding the current behavior of the rule. It comes from the fact that some variables (and constraints in the symbolic execution engine) are sometimes not considered alive when they still should.
A ticket has been created to tackle this: SONARJAVA-2951
I saw that the linked jira ticket (SONARJAVA-2873) has been fixed, so I marked the comment where you linked it as a solution. Is that the correct usage of “solutions”?