Getting code statistics from big projects
I'm interested in code statistics tools. Specifica开发者_Go百科lly I need to get statistics on Java EE code, but any code analyzer would do. Should I start creating one of my own or is there some project that you have used?
ex. LOC, number of classes , libs ...
What is your experience ?
As explained by jitter, Sonar is definitively the tool that you are looking for. Note that this tool used JavaNCSS, but since the version 1.9, they have their own internal tool (called SonarSquid) that is really totally compatible with Java 1.5 or 1.6 projects.
alt text http://sonar.codehaus.org/wp-content/uploads/2009/05/sonar-squid.jpg
In addition, you can monitor a complete set of projects.
You can access the Nemo demo instance to have a complete overview of the tool!
I've already used Metrics Eclipse Plugin. It's outdated nowadays, but has a number of interesting metrics.
There's StateOfFlow too. It supports less metrics, but it seems it's not so outdated.
You can use JavaNCSS - A Source Measurement Suite for Java which supports some basic metrics (NCSS, # classes/packages/functions, CCN).
Then there is Sonar which supports some 20+ code metrics and Clover (where you even can define your own metrics with in a special language)
If that isn't enough for you can google for "java" and "metrics"
One tool, which gathers quite niche statistics is Testability Explorer. It operates on Java byte code, providing stats for cyclomatic complexity, mutable global state and some other things. It's free and open-source under the Apache 2.0 license.
As I said it is very niche, and probably won't give metrics which are as easy to relate to as LOC. However, what's interesting is that you would be able to compare the projects you run it on against several well known open-source projects. This would perhaps make the results more useful.
Another tool which I recently used is SLOCCount. It's a command line tool designed to give statistics for many different languages, including Java. After failing to run JavaNCSS on a large codebase (it complained of too many files) I got this tool running no problem, for a very large codebase (IntelliJ IDEA). A nice feature is that it takes very little configurability, I didn't even have to tell it to look for *.java
files, it recognised different languages automatically and reported on them.
The downside to SLOCCount is if you're running Windows - you'll have to use Cygwin to run it.
The SD Java Metrics Tool provides SLOC, comment count, Halstead and Cyclomatic complexity numbers, down to the method level and for all rollups larger than that (method, class, file, directory, ...)
The SD Java Clone Doctor analyzes software systems for code duplication, and provides a complete list of detected clones, typically 10-20% in large software systems. You can see a clone detection report at the link.
The SD Source Code Search Engine indexes your source code base to provide lightning-fast searches across millions of lines of code. As a byproduct of indexing the source base, it produces file-level statistics for SLOC, comment count, Halstead and Cyclomatic numbers. It operates on Java, C#, and many other languages.
For eclipse you could try Emma (code coverage) and JDepend (design quality metrics)
You can try also JavaDepend,it provides more than 82 metrics, and CQL ( SQL like) to query code base make it flexible.
And the metric view give you visually a good idea of SLOC,Complexity and other ineresting metrics.
精彩评论