简体   繁体   English

Java代码分析/指标工具

[英]Java code Analytic/Metrics tool

I am looking for a free Java code analysis/metrics tool that I can use to see class dependencies, method execution times, etc, and possibly to print out a diagram that shows them. 我正在寻找一个免费的Java代码分析/度量工具,可以用来查看类依赖关系,方法执行时间等,并可能打印出显示它们的图表。 I am currently using a jdepend task in ANT to achieve this, but I'm thinking there must be a better tool for that sort of thing. 我目前在ANT中使用jdepend任务来实现此目的,但是我认为对于这种事情必须有更好的工具。 I would also prefer if it was integrated with Netbeans, since I'd rather not port all my projects to Eclipse for the task of analyzing. 我还希望将其与Netbeans集成,因为我不想将所有项目都移植到Eclipse来进行分析。 I have tried to play with the community version of Visual Paradigm, but I got sick of it really fast when it didn't offer code synchronization in the community edition. 我尝试过使用Visual Paradigm的社区版本,但是当它在社区版本中不提供代码同步时,我很快就厌倦了它。 Although I can give it another shot if that is indeed the way to go. 尽管如果确实可以,我可以再给一个机会。 I also tried BOUML, but it seems to be more of a UML design tool than an existing code analyzer. 我也尝试过BOUML,但它似乎比现有的代码分析器更像是UML设计工具。 So, my question is, what do you guys use for Java code analysis? 所以,我的问题是,你们在Java代码分析中使用什么? Thanks! 谢谢!

EDIT: For instance, JDepend measures a few metrics and can draw a nice little dependency graph, but it doesn't exactly have a UI or anything. 编辑:例如,JDepend测量一些指标,并且可以绘制一个漂亮的小依赖图,但是它没有UI或其他任何东西。 I guess I'm looking for a tool that can draw out all my classes and their dependencies on each other (jdepend only does packages AFAIK) as well as the methods that are called between the classes and provides a metric number of "how good the code structure is". 我猜我在寻找一种工具,该工具可以绘制我所有的类及其彼此之间的依赖关系(jdepend仅会封装AFAIK)以及在类之间调用的方法,并提供度量标准“代码结构是”。 I apologize if the question is vague, I'm just looking for a variety of options and I don't exactly have a lot of experience with code metrics tools... 如果问题不清楚,我深表歉意,我只是在寻找各种各样的选择,而我在代码指标工具方面并没有很多经验...

As @Victor has mentioned Sonar is a very good tool for static code analysis. 正如@Victor提到的, Sonar是用于静态代码分析的非常好的工具。 It produces graphs, charts, and generally allows you to slice and dice your Java code analysis in multiple ways. 它产生图形,图表,并且通常允许您以多种方式对Java代码分析进行切片和切块。

However, it does run as a server, which can require privileges on your machine/network that you might not have. 但是,它确实作为服务器运行,这可能需要您可能没有的计算机/网络特权。 I use it myself, and I recommend it, but it's not always practical. 我自己使用它,并推荐使用它,但这并不总是实用的。 So let's take a look at some of the tools that it uses underneath the hood. 因此,让我们看一下它在引擎盖下使用的一些工具。

First, there's FindBugs . 首先,有FindBugs As the name implies, it helps you find bugs in your Java source code. 顾名思义,它可以帮助您查找Java源代码中的错误。

Next, there's PMD . 接下来是PMD It helps find bugs in different ways from FindBugs. 它可以通过FindBugs以不同的方式帮助查找错误。

Third, there's CheckStyle . 第三,有CheckStyle It helps ensure that your code conforms to certain style guidelines. 它有助于确保您的代码符合某些样式准则。

Finally, there's Cobertura , which instruments your Java bytecodes and analyzes which source code lines are exercised by your unit tests (you do have unit tests, right?) 最后,还有Cobertura ,它可以检测您的Java字节码并分析单元测试将使用哪些源代码行(您确实有单元测试,对吗?)

This is not an exhaustive list of the tools that Sonar employs, but it covers what seem to be the highlights. 这不是Sonar使用的工具的详尽列表,但涵盖了似乎是重点的内容。 Inside Sonar, these are all 100% configurable. 在Sonar内部,所有这些都是100%可配置的。 Outside Sonar, they're still configurable, but you better like XML. 在Sonar之外,它们仍然是可配置的,但是您最好喜欢XML。

Sonar. 声纳 Though, personally I've never used it, so I can't answer questions about details. 但是,就我个人而言,我从未使用过它,所以我无法回答有关细节的问题。 However, I know that our conitnuos building tool is integrated with it to make pretty pictures :) 但是,我知道我们的conitnuos构建工具已与它集成在一起,可以绘制漂亮的图片:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM