Reputation: 111
I'm trying to setup Sonar on our organization that we mostly make Unity projects.
Our problem is that the rules provided to C# language are not always the same in Unity context.
https://docs.unity3d.com/ScriptReference/MonoBehaviour.html
So in this case I have tons of "Remove this unused private member".
Is there a way to tell, don't apply that rule if my class derives from MonoBehaviour (or AssetPostprocessor, etc...) and my method name is for example "Awake"? I mean, is there a way to set a custom rule and invalidate other one?
https://docs.unity3d.com/ScriptReference/SerializeField.html
In this case I get tons of "Make "{FIELD}" "readonly"" if my field has a default value because it's Unity then who "fills" that value updated/changed from inspector but if I make it readonly it won't work in Unity's serialization system.
Thanks.
Upvotes: 3
Views: 2486
Reputation: 6420
Thank you for reporting these issues. We haven't tested Unity projects with SonarQube, but it's on our radar as the community and the Unity based code base is huge.
At this point I can't suggest any other workaround for your first problem (convention based reflection) but to disable that rule. I created a JIRA ticket to investigate the options: https://jira.sonarsource.com/browse/SLVS-1104
And here is the ticket for the readonly field problem. That's definitely something that can be easily fixed. It will be part of the next release: https://jira.sonarsource.com/browse/SLVS-1105
Upvotes: 4