How to suppress the StyleCop warnings globally in the solution?
The solution is continually built using Jenkins (continuous build and integration tool), and it applies all the StyleCop rules. The solution uses TAB character instead of 4 spaces as it is the standard taken by my dev team. Because of this, several SA1027 warnings are thrown by StlyeCop.
How do I remove SA1027 warning from Jenkins? That would also help.
Giving the SuppressMessage on every C# file would not look nice. That's why I am looking for a global suppression approach.
If you migrate a project to Visual Studio 2019, you might suddenly be faced with a large number of code analysis warnings. If you aren't ready to fix the warnings, you can suppress all of them by selecting Analyze > Build and Suppress Active Issues.
StyleCop used to be a Visual Studio plugin and a NuGet package. You can still use this in Visual Studio 2019, but the current recommended way to use StyleCop is to use the Roslyn-based analyzers.
In your StyleCop install, there's a Settings. StyleCop file. You can edit this to turn off rules globally. Drag that file onto the Settings Editor executable in that file to edit it.
StyleCop doesn't support the notion of global suppression of a rule. It requires the SuppressMessage
attribute be placed on the given code element.
From the Source Analysis Blog (Source)
StyleCop does not support the notion of global suppressions or file-level suppressions. Suppressions must be placed on a code element.
One option though is to simply turn off the rules that you aren't interested in. This is the preferred method of global suppression.
Seems that you probably need to change StyleCop configuration (settings) than to suppress some rules globally. StyleCop settings are "inherited through file system" so you could just create an appropriate settings file at the level of your solution folder.
Regarding your specific "tabs vs. spaces" subject, you could not only turn off StyleCop rules that requre spaces, but also to use some StyleCop plugins (like StyleCop+) that contains rules requiring tabs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With