The rule which detects unused code (csharpsquid:S1144) does not work for razor pages/code behind files. Any method/member which is actually referenced in the razor page for event is flagged in sonar lint. I’m not sure this is a problem outside of sonar lint because I don’t see it listed as an issue once the code has been uploaded to sonarcloud.
Unfortunately, I have to remove this rule for now so that it doesn’t cause developers so much grief/paranoia when writing code.
edit: The same applies to rule csharpsquid:S4487
Is it at least possible for me to exclude these rules on any files matching this wildcard pattern: *.razor* ?
Sorry for the very late reply, for some reason this thread was missed by our team.
I struggle to reproduce because when I create a Razor page in Rider, it is using MVC pattern (so the page can only access public methods of the model).
Thanks for the update.
Can you try it with a blazor server app? Not sure if that makes a difference. I believe I did something to ignore this rule alrogether, temporarily, so I’ll enable it again and look to see if it’s still happening if you still don’t see any issues in the latest version of Rider.
Thanks for sharing this. We are currently exploring including the C# in .cshtml and .razor files in our analysis and I hope that this will resolve this issue. As you can imagine this is quite a big step and we are in the early stages but initial signs look promising. I’ll try and update this post as things progress.
While our C# analysis on SonarQube and SonarCloud now supports razor analysis, we do not support it in SonarLint (it’s challenging to do so with our current implementation of OmniSharp). Still, we’ve passed your feedback along to the relevant folks (the more traction, the more likely we move on it).