从大型项目中获取代码统计信息
我对代码统计工具感兴趣。具体来说,我需要获取 Java EE 代码的统计信息,但任何代码分析器都可以。我应该开始创建自己的项目还是您已经使用过某个项目?
前任。 LOC、类数、库...
您的经验是什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我对代码统计工具感兴趣。具体来说,我需要获取 Java EE 代码的统计信息,但任何代码分析器都可以。我应该开始创建自己的项目还是您已经使用过某个项目?
前任。 LOC、类数、库...
您的经验是什么?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(7)
正如 jitter 所解释的,Sonar 绝对是您正在寻找的工具。
请注意,该工具使用 JavaNCSS,但从 1.9 版本开始,他们有自己的内部工具(称为 SonarSquid),该工具实际上与 Java 1.5 或 1.6 项目完全兼容。
替代文本 http://sonar.codehaus.org/wp -content/uploads/2009/05/sonar-squid.jpg
此外,您还可以监控一整套项目。
您可以访问 Nemo 演示实例 以全面了解该工具!
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!
我已经使用过 Metrics Eclipse 插件。如今它已经过时了,但有许多有趣的指标。
还有 StateOfFlow。它支持的指标较少,但似乎并没有那么过时。
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.
您可以使用 JavaNCSS - Java 源测量套件,它支持一些基本指标( NCSS,# 类/包/函数,CCN)。
然后是 Sonar,它支持大约 20 多个代码指标和 Clover(您甚至可以用特殊语言定义自己的指标)
如果这还不够,您可以在 google 上搜索“java”和“指标”
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"
Testability Explorer 是一种收集相当小众统计数据的工具。它在 Java 字节码上运行,提供圈复杂度、可变全局状态和其他一些东西的统计数据。它是免费且开源的,遵循 Apache 2.0 许可证。
正如我所说,它非常小众,并且可能不会提供像 LOC 那样容易关联的指标。然而,有趣的是,您可以将运行它的项目与几个众所周知的开源项目。这也许会使结果更有用。
我最近使用的另一个工具是SLOCCount。它是一个命令行工具,旨在提供许多不同语言(包括 Java)的统计信息。在大型代码库上运行 JavaNCSS 失败后(它抱怨文件太多),对于非常大的代码库(IntelliJ IDEA),我让这个工具运行没有问题。一个很好的功能是它只需要很少的可配置性,我什至不必告诉它寻找
*.java
文件,它会自动识别不同的语言并报告它们。SLOCCount 的缺点是,如果您运行的是 Windows,则必须使用 Cygwin 来运行它。
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.
SD Java Metrics Tool 提供 SLOC、评论计数、Halstead 和 Cyclomatic 复杂度数字,深入到方法级别以及所有大于该级别的汇总(方法、类、文件、目录...)
SD Java Clone Doctor 分析软件系统的代码重复,并提供检测到的克隆的完整列表,通常在大型软件系统中占 10-20%。您可以在链接中查看克隆检测报告。
SD 源代码搜索引擎 对您的源代码库进行索引,以提供对数百万个源代码的快速搜索代码行。作为对源库进行索引的副产品,它会生成 SLOC、评论计数、Halstead 和 Cyclomatic 数字的文件级统计信息。它可以在 Java、C# 和许多其他语言上运行。
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.
对于 Eclipse,您可以尝试 Emma (代码覆盖率)和 JDepend(设计质量指标)
For eclipse you could try Emma (code coverage) and JDepend (design quality metrics)
您也可以尝试 JavaDepend,它提供了超过 82 个指标,以及 CQL(类似 SQL)来查询代码库它灵活。
指标视图让您直观地了解 SLOC、复杂性和其他有趣的指标。
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.