[ACCEPTED]-Calculate code metrics-metrics
On my latest project I used SourceMonitor. It's a nice 5 free tool for code metrics analysis.
Here 4 is an excerpt from SourceMonitor official 3 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 2 best tool, I can recommend vil.
Following tools 1 can perform trend analysis:
Sonar is definitively a tool that you must consider, especially 5 for Java projects. However it will also 4 handle PHP or C/C++, Flex and Cobol code.
Here 3 is a screenshot that show some metrics on 2 a project:
alt text http://sonar.codehaus.org/wp-content/uploads/2009/05/squid-metrics.png
Note that you can try the tool 1 by using their demo site at http://nemo.sonarsource.org
I was also looking for a code metrics tool/plugin 19 for my IDE but as far as I know there are 18 none (for eclipse that is) that also show 17 a graph of the complexity over a specified 16 time period. However, I did find the eclipse metrics plugin, it 15 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 14 miss the graphing option you are seeking 13 as well.
I think that, if you don't find 12 any plugins/tools that can handle the graphing 11 over time, you should look at the tool that 10 suits you most and offers you all the information 9 you need; even if the given information 8 is only for the current build of your project.
As 7 a side note, the eclipse metrics plugin allows you to export the data to an external file (link goes 6 to an example), so if you use a source control 5 tool, and you should!, you can always export 4 the data for the specific build and store 3 the file along with the source code, that 2 way you still have a (basic) way to go back 1 in time and check the differences.
keep in mind, What you measure is what you 6 get. loc says nothing about productivity 5 or efficency.
rate a programmer by lines 4 of code and you will get.. lines of code. the 3 same argument goes for other metrics.
otoh.. http://www.crap4j.org/ is 2 a very conservative and useful metric. it 1 sets complexity in relation with coverage.
NDepend, I am using it and its best for 1 this purpose. Check this : http://www.codeproject.com/KB/dotnet/NDepend.aspx
Concerning the tool NDepend it comes with 82 different 10 code metric, from Number of Lines of Code, to 9 Method Rank (popularity), Cyclomatic Complexity, Lack 8 of Cohesion of Methods, Percentage Coverage 7 (extracted from NCover or VSTS), Depth of 6 Inheritance...
With its rule system, NDepend 5 can also find issues and estimates technical debt which 4 is an interesting code metric (amount of 3 dev-effort to fix problems vs. amount of dev-time 2 spoiled per year to let problems unfixed).
All 1 these metrics are detailled here.
If you're in the .NET space, Developer Express' CodeRush provides 5 LOC, Cyclomatic Complexity and the (rather 4 excellent, IMHO) Maintenance Complexity analysis of code in real-time.
(Sorry 3 about the Maintenance Complexity link; it's 2 going to Google's cache. The original seems 1 to be offline ATM).
Atlassian FishEye is another excellent tool 8 for the job. It integrates with your source 7 control system (currently supports CVS, SVN 6 and Perforce), and analyzes all your files 5 that way. The analysis is rather basic though, and 4 the product itself is commercial (but very 3 reasonably priced, IMO).
You can also get 2 an add-on for it called Crucible that facilitates 1 peer code reviews.
For Visual Studio .NET (at least C# and 4 VB.NET) I find the free StudioTools to be extremely 3 useful for metrics. It also adds a number 2 of features found in commercial tools such 1 as ReSharper.
I would recommend Code Metrics Viewer Exention for visual studio.
It 3 is very easy to analyze solution at once, also 2 do comparison if you made progress ;-)
On the PHP front, I believe for example 7 phpUnderControl includes metrics through phpUnit (if I am not 6 mistaken).
Keep in mind that metrics are 5 often flawed. For example, a coder who's 4 working on trivial problems will produce 3 more code and there for look better on your 2 graphs, than a coder who's cracking the 1 complex issues.
If you're after some trend analysis, does 18 it really mean anything to measure beyond 17 SLOC?
Even if you just doing a grep for trailing 16 semi-colons and counting the number of lines 15 returned, what you are after is consistency 14 in the SLOC measurement technique. In this 13 way today's measurement can be compared 12 with last month's measurement in a meaningful 11 way.
I can't really see what would a trend 10 of McCabe Cyclometric Complexity give? I 9 think that CC should be used more for a 8 snapshot of quality to provide feedback 7 to the developers.
Edit: Ooh. Just thought 6 of a couple of other measurements that might 5 be useful. Comments as a percentage of SLOC 4 and test coverage. Neither of which you 3 want to let slip. Coming back to retrofit 2 either of these is never as god as doing 1 them "in the heat of the moment!"
HTH.
cheers,
Rob
Scitools' Understand does have the capability to generate a 5 lot of code metrics for you. I don't have 4 a lot of experience with the code metrics 3 features, but the static analysis features 2 in general were nice and the price was very 1 reasonable. The support was excellent.
Project Code Meter gives a differential development history 7 report (in Excel format) which shows your 6 coding progress metrics in SLOC, time and 5 productivity percentage (it's time estimation 4 is based on cyclomatic complexity and other 3 metrics). Then in Excel you can easily produce 2 the graph you want.
see this article which 1 describes it step by step: http://www.projectcodemeter.com/cost_estimation/help/FN_monsizing.htm
For Java you can try our tool, QualityGate that computes 4 more than 60 source code metrics, tracks 3 all changes through time and also provides 2 an overall rating for the maintainability 1 of the source code.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.