C# rule - S2228


(Bogdan Ungureanu) #1


I’m using SonarQube - on premise installation - and I configured a set of rules as part of a quality profile.
One of the rules I’m interested is " Console logging should not be used".

One of the exceptions of this rule is for console applications - there, this rule shouldn’t apply.

My question is - how does the scanner detect that the application is a console application? I have one as such and this rule is still getting triggered.

How should I configure my sonar properties or the C# project itself so that this rule is not getting applied?

Thank you!

(Valeri Hristov) #2

Hi Bogdan,

S2228 is checking if the OutputKind of the compilation is ConsoleApplication and if it is, no issues are raised. I think this corresponds to the Output Type dropdown in the project properties…

I tested with a new .NET Desktop Console Application and a new .NET Core Console Application and the rule did not raise issues (I had to enable it because it is not enabled by default).

Kind regards,