Selectively Disabling Cyclomatic Complexity
Selectively Disabling Cyclomatic Complexity
I'd like to be able to manually set the Cylcomatic Complexiy of a method.
We have scripts which prevent code reaching our mainline that has an unacceptably large cyclomatic complexity - i.e. we don't want our methods to become unmaintainably complex. However, we have some perfectly maintainable methods that contain switch statements, and perfectly maintainable switch statements can have a large c.c.
We still want converage statistics for these methods, so making NCover ignore them is not a great solution.
Is this possible? Can we either stop the c.c. calculation for a particular method, or manually override it somehow?
RE: Selectively Disabling Cyclomatic Complexity
There is a way to adjust maximum and acceptable cyclomatic complexity thresholds, but it's not exposed in NCover Explorer. Also, due to the complexity of supporting methods (generics, overloaded methods, etc) the adjustment mechanism only supports down to the class level at this time. There's a through overview available at the following URL:
http://docs.ncover.com/how-to/advanced-reporting-features/#satisfactory
Example, lets say that the "Trading.StockMarket.Monitor" class has a bunch of conversion methods with large switch statements in them. You can set the acceptable Cyclomatic Complexity for the class higher than the default of 20 (t osay, 80) with the following command
ncover.reporting.exe //sct CyclomaticComplexity:80:Class:Trading.StockMarket.Monitor