Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

My Cyclomatic Complexity Thresholds

When anaylizing some cyclomatic complexity (measures the number of linearly-independent paths through a program module), I was thinking to myself about where I want my thresholds to be.  Where to I say “this is simple enough” or “I definately need to refactor this”.

So here is my conclusion:

  • 1–10  Simple enough.  Don’t change.  Little risk involved.
  • 11–20  Should consider refactoring.  Moderate risk involved.
  • 21–40  Definate refactoring needed here.  Risk is too high.
  • > 41  What was I thinking?  Throw this away and start over.

I won’t find anything in the greater than 41 range, but if I were to find anything, I’d definately throw it away.

This entry was posted in .Net Development, Patterns and Practices. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

5 Responses to My Cyclomatic Complexity Thresholds

  1. Josh Adams says:

    Raymond, I was just blogging about this topic: http://devreflection.wordpress.com/2007/06/11/cyclomatic-complexity-and-refactoring/

    Do you have any suggestions for the scenario I describe in the post (specifically I’ve got a class that’s a concrete implementation of System.Xml.XPath.XmlNavigator–lots of abstract methods are defined on that class ;( )?

  2. Have a look at FxCop or the Managed Code Analysis in Team System.

    Doesn’t analyze source code but rather the binary and also does CCC (Team System version only).

  3. rlewallen says:

    I posted this before I saw Sahil’s comment, but here is a link to some tools I use: http://www.codebetter.com/blogs/raymond.lewallen/archive/2005/06/13/64539.aspx

  4. Eric Marthinsen says:

    Are there any solid tool for doing source code analysis of .NET programs?

Leave a Reply