views:

628

answers:

5

I'm looking for a tool that can provide code quality metrics.
For instance it could report

  • very long functions (spaghetti code)
  • very complex classes (which could contain do-it-all code)
  • ...

While we're on the (subjective:-) subject of code quality, what other code metrics would you suggest?

I'm targetting C#/.NET code, but I'm sure this could extend to most programming languages.

+4  A: 

I recommend SourceMonitor. As far as metrics go, I usually use cyclomatic complexity -- any function with a CC of higher than 20 is a good candidate for refactoring. Also, it's free.

Visual Studio 2008 Team System also has code metrics built in.

rlbond
+5  A: 

You could try looking at FxCop (http://msdn.microsoft.com/en-us/library/bb429476.aspx).

Edit: Actually, there is a page on wikipedia as well (on tools for Static Analysis). (http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis).

MatthieuF
+3  A: 

What you need is NDepend.

idursun
+6  A: 

Have a look at NDepend features. With NDepend you will pinpoint easily quality flaw of your code base. The tool supports 82 code metrics and several facilities to sort and visualize metric problematic values.

NDepend can also help rationalizing architecture, see how a code base evolve over time, explore coverage by tests, define and check any kind of rules your team should follow, detect build process flaws...

Patrick Smacchia - NDepend dev
I would LOOOOOOOOOOVE that for C.
Chris Nelson
Chris, have a look at CppDepend then :o)
Patrick Smacchia - NDepend dev
+1  A: 

Visual Studio 2008 Team System Development Edition (and Team Suite) has some code metrics included: Analyze | Calculate Code Metrics

Richard