Welcome to the community and thanks for this report!
Can you give your context for this? I.e. are you on SonarQube Cloud? SonarQube for IDE (flavor and version)? SonarQube self-managed (flavor and version)?
This was initially spotted by a colleague using SonarLint 8.4.0 in IntelliJ IDEA 2025.3. It’s an older version of the plugin as it binds to an older version of SonarQube server (self-managed) Version 7.9.2 (yes, we really do need to upgrade but are restricted due to the project).
On seeing the example text I checked the ruleset on our SonarQube server, and then checked whether the same example existed within the SonarQube codebase (to check if it had been addressed on the newer versions).
I cannot currently try to recreate on a newer version of SonarQube (I don’t have access until we upgrade) - I raised this based on the source on the “master” branch within github, which currently includes the inappropriate example for S2301.
Thanks for the explanation. I’ll flag this for the language experts.
And in a separate thread, I’d love to explore how we can get you to a current version of SonarQube. I’m 85% certain that accommodations could be made on a current SonarQube version for the project that’s holding you on a version that’s nearly 6 years old.