Search code examples
c#msbuildjenkinsstylecop

Suppressing the StyleCop Warnings at the global level


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.


Solution

  • 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.