Hello @Michael_Berner,
Thanks for your message. Unfortunately, I’m not able to reproduce your issue.
And I think I know why. This rule actually relies on the compiler warnings and we had a bunch of problems with this in the past.
The reason why this error is happening is most likely in the incomplete semantic model. So in order to check it I need a little bit more input from your side:
-
logs
-
sonar analysis configuration
-
Are you using Gradle or Maven?
Also, your problem might be similar to this thread: "Unused local variables should be removed" is broken - #8 by Margarita_Nedzelska
And we also have a ticket in the backlog that might help to improve this rule:
https://sonarsource.atlassian.net/browse/SONARKT-269
Looking forward to your answer!
Regards,
Margarita