Using it with Unity 3D tons of problems

109 views
Skip to first unread message

iam....@gmail.com

unread,
Dec 5, 2016, 3:02:48 PM12/5/16
to SonarQube
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.

1. In Unity there is a MonoBehaviour class that if you declare some methods (Awake, Start) they are being called by reflection:


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?

2. The same applies to Unity serialization system. You can have a private field with [SerializeField] attribute and it gets automatically initialized by Unity:


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.

Tamas Vajk

unread,
Dec 7, 2016, 11:55:54 AM12/7/16
to iam....@gmail.com, SonarQube
Hello,


Tamas

Tamas VAJK | SonarSource
Language Team

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/d6a2eb22-7013-4181-b53f-1ad966afd6f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

iam....@gmail.com

unread,
Dec 7, 2016, 12:11:36 PM12/7/16
to SonarQube, iam....@gmail.com
Sorry I read it later that you also actively follow "sonarqube" tags, you can delete this thread if you want.

Thanks!


El miércoles, 7 de diciembre de 2016, 17:55:54 (UTC+1), Tamas Vajk escribió:
Hello,


Tamas

Tamas VAJK | SonarSource
Language Team

On 5 December 2016 at 21:02, <iam....@gmail.com> wrote:
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.

1. In Unity there is a MonoBehaviour class that if you declare some methods (Awake, Start) they are being called by reflection:


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?

2. The same applies to Unity serialization system. You can have a private field with [SerializeField] attribute and it gets automatically initialized by Unity:


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.

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages