views:

3605

answers:

17

Are there any tools available that will calculate code metrics (for example number of code lines, cyclomatic complexity, coupling, cohesion) for your project and over time produce a graph showing the trends?

+7  A: 

NDepend for .net

IainMH
+24  A: 

On my latest project I used SourceMonitor. It' very nice free tool for code metrics analysis.
Here is an excerpt from SourceMonitor official site:

  • Collects metrics in a fast, single pass through source files.
  • Measures metrics for source code written in C++, C, C#, VB.NET, Java, Delphi, Visual Basic (VB6) or HTML.
  • Includes method and function level metrics for C++, C, C#, VB.NET, Java, and Delphi.
  • Saves metrics in checkpoints for comparison during software development projects.
  • Displays and prints metrics in tables and charts.
  • Operates within a standard Windows GUI or inside your scripts using XML command files.
  • Exports metrics to XML or CSV (comma-separated-value) files for further processing with other tools.

For .NET beside NDepend which is simply the best tool, I can recommend vil

Following tools can perform trend analysis:

aku
SourceMonitor seems to be a Windows-only tool. Exists something similar for other Operating Systems (Linux, BSD, Mac)?
Mnementh
Mnementh, I'm windows dev, I don't know any such tools for FOSS guys. Maybe you can try to run SourceMonitor under Wine emulator?
aku
Now there is a NDepend-type tool for C++, CppDepend
Goosey
+2  A: 

If you're in the .NET space, Developer Express' CodeRush provides LOC, Cyclomatic Complexity and the (rather excellent, IMHO) Maintenance Complexity analysis of code in real-time.

(Sorry about the Maintenance Complexity link; it's going to Google's cache. The original seems to be offline ATM).

moobaa
+5  A: 

I was also looking for a code metrics tool/plugin for my IDE but as far as I know there are none (for eclipse that is) that also show a graph of the complexity over a specified time period. However, I did find the eclipse metrics plugin, it can handle:

  • McCabe's Cyclomatic Complexity
  • Efferent Couplings
  • Lack of Cohesion in Methods
  • Lines Of Code in Method
  • Number Of Fields
  • Number Of Levels
  • Number Of Locals In Scope
  • Number Of Parameters
  • Number Of Statements
  • Weighted Methods Per Class

And while using it, I didn't miss the graphing option you are seeking as well.
I think that, if you don't find any plugins/tools that can handle the graphing over time, you should look at the tool that suits you most and offers you all the information you need; even if the given information is only for the current build of your project.

As a side note, the eclipse metrics plugin allows you to export the data to an external file (link goes to an example), so if you use a source control tool, and you should!, you can always export the data for the specific build and store the file along with the source code, that way you still have a (basic) way to go back in time and check the differences.

Sven
A: 

For Python, pylint can provide some code quality metrics.

Readonly
A: 

On the PHP front, I believe for example phpUnderControl includes metrics through phpUnit (if I am not mistaken).

Keep in mind that metrics are often flawed. For example, a coder who's working on trivial problems will produce more code and there for look better on your graphs, than a coder who's cracking the complex issues.

Till
+1  A: 

There's also a code metrics plugin for reflector, in case you are using .NET.

Tobi
A: 

If you're after some trend analysis, does it really mean anything to measure beyond SLOC?

Even if you just doing a grep for trailing semi-colons and counting the number of lines returned, what you are after is consistency in the SLOC measurement technique. In this way today's measurement can be compared with last month's measurement in a meaningful way.

I can't really see what would a trend of McCabe Cyclometric Complexity give? I think that CC should be used more for a snapshot of quality to provide feedback to the developers.

Edit: Ooh. Just thought of a couple of other measurements that might be useful. Comments as a percentage of SLOC and test coverage. Neither of which you want to let slip. Coming back to retrofit either of these is never as god as doing them "in the heat of the moment!"

HTH.

cheers,

Rob

Rob Wells
+1  A: 
Prakash
A: 

keep in mind, What you measure is what you get. loc says nothing about productivity or efficency.

rate a programmer by lines of code and you will get.. lines of code. the same argument goes for other metrics.

otoh.. http://www.crap4j.org/ is a very conservative and useful metric. it sets complexity in relation with coverage.

Andreas Petersson
+2  A: 

Concerning the tool NDepend it comes with 82 different code metric, from Number of Lines of Code, to Method Rank (popularity), Cyclomatic Complexity, Lack of Cohesion of Methods, Percentage Coverage (extracted from NCover or VSTS), Depth of Inheritance...

All these metrics are detailled here.

Patrick Smacchia - NDepend dev
A: 

Scitools' Understand does have the capability to generate a lot of code metrics for you. I don't have a lot of experience with the code metrics features, but the static analysis features in general were nice and the price was very reasonable. The support was excellent.

andreas buykx
+1  A: 

Atlassian FishEye is another excellent tool for the job. It integrates with your source control system (currently supports CVS, SVN and Perforce), and analyzes all your files that way. The analysis is rather basic though, and the product itself is commercial (but very reasonably priced, IMO).

You can also get an add-on for it called Crucible that facilitates peer code reviews.

Jack Leow
A: 

check out dev \ efor i guess it's exactly what you need

+1  A: 

NDepend, I am using it and its best for this purpose. Check this : http://www.codeproject.com/KB/dotnet/NDepend.aspx

abhishek
+1  A: 

Sonar is definitively a tool that you must consider, especially for Java projects. However it will also handle PHP or C/C++, Flex and Cobol code.

Here is a screenshot that show some metrics on a project:

alt text

Note that you can try the tool by using their demo site at http://memo.sonarsource.org

romaintaz
+1  A: 

For Visual Studio .NET (at least C# and VB.NET) I find the free StudioTools to be extremely useful for metrics. It also adds a number of features found in commercial tools such as ReSharper.

Topdown