Roslyn has recently (June 2019) exposed a new API, DiagnosticSuppressor, which allows to suppress warnings programmatically. Is SonarQube planning to take advantage of this new API anytime soon? When running the latest version, with default configuration, the false-positive warnings are still triggered. I don’t know if I’m missing something or if it’s not implemented yet.
When dealing with code analysis in a Unity engine context, we were constrained to face false-positive warnings for a long time. The most common one is
warning CS0649: Field 'NewBehaviourScript.x' is never assigned to, and will always have its default value null. It happens when you are actually assigning a variable through the Unity Editor inspector, if the said variable is decorated with [SerializeField] attribute, which allows variable assignation at editor-time even for private variables.
For more details about this issue, you can read this thread on Roslyn GitHub:
Until now, we had two options to get rid of these false-positive warnings: either insert
pragma supress warning everywhere, or disable completely the related rule (with the obvious side of effect of hiding real positive warnings). Neither were satisfying.
Since there is now a nice solution provided by Roslyn, a request on Unity forum is asking for an internal Roslyn update, and usage of DiagnosticSuppressor API, in order to hide false-warning from Unity Editor console:
Anything planned regarding SonarQube?