I have a method that goes through loads of file types like so:
case ".jpg":
res = "image/jpeg";
break;
case ".pdf":
res = "application/pdf";
break;
case ".doc":
res = "application/msword";
break;
..this goes on for a few hundred lines. And I have run into a StyleCop error: SP2101: Method body must not contain more than 120 code lines
I have searched around and can't find anything on this, let alone the suppression. Does anyone know how to suppress this message?
Edit: I think this is a StyleCop+
error and cannot be solved using the FxCop program to copy the suppression.
I am the author of StyleCop+.
One of the rule it adds to original StyleCop functionality is indeed SP2101 (MethodMustNotContainMoreLinesThan) which checks the size of your method.
Like any other StyleCop warning, it could be:
Moreover, it is configurable. If you want to use this rule, you can put any number instead of 120 for your own configuration. 120 is just some default.
The point of this rule is around maintainability. It could be very important to check that you don't fall into spaghetti code. StyleCop is just a tool giving you an ability to get control over that. StyleCop+ offers some more rules to check. So if you wish to use them - go ahead. If you don't - just disable it. It is kind of a tool that really needs to be configured before the usage.
Let me know if you need any help with configuration.