8

Just wondering, I have installed CodeMaid for Visual Studio and getting code quality stats on a large codebase. i see numbers ranging from 1 to 300 on many of the methods. How much is too much? Can we (or should we) even have a threshold for something like this?

Ahsan
  • 2,488
  • 2
  • 22
  • 44
  • 3
    You should probably set a threshold that is based on experience, typically a CC of 10-15 is used as an indication that refactoring may be needed. Sometimes CC is impossible to reduce and still have the code be correct, so take it with a grain of salt. On the other hand, if you have CC values in the 100's, personally I'd say some refactoring is needed. See http://en.wikipedia.org/wiki/Cyclomatic_complexity – Ron Beyer May 26 '15 at 02:57

1 Answers1

10

Exact number is team/personal opinion based, but 100+ is definitely way too high.

Microsoft's recommendation is 25:

CA1502: Avoid excessive complexity

The rule reports a violation when the cyclomatic complexity is more than 25.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179