[java:S1133] FP, if forRemoval=false

Qube: Community 9.9

The Java rule S1133 reminds me of removing a deprecated element. But if it is annotated with


this is an FP.

1 Like

Hello @mfroehlich, thank you for reaching out and questioning rule S1133.

The @Deprecated is used to discourage the use of a specific element for several reasons, independently from the fact that it will be removed or not in a future release.

The element forRemoval is false by default and it is not intended to justify the use of a deprecated element, rather it highlights the urgency to replace such code. For such a reason the rule is valid independently from the presence of forRemoval.

I hope this explanation makes sense to you.


Hmm… maybe I mixed up the rules then.

For a deprecated element like a method I always get two findings from sonar. One finding tells me to add since and/or forRemoval attributes to the annotation. The othe finding reminds me of removing the deprecated method eventually. Of course there may be other findings, that tell me to replace the code, that uses the deprecated method. But that’s not, what I mean.

The second finding, that reminds me of removing the deprecated method (“Don’t forget to remove deprecated method”), should not come up, if the method is deprecated with forRemoval=false.

Hope, that makes things a little clearer.

1 Like

Hello @mfroehlich, thanks for clarifying.

Initially, I misunderstood the rule, and after checking the rule your point is valid. Apparently, the rule was implemented before SDK 9 and thus it’s not supporting the element forRemoval.

You can track the progress for this fix through [SONARJAVA-4595] - Jira.

Thank you

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.