Java Tools: Source Code Optimization and Analysis[转]

Below is a list of some tools that can help you examine your Java source code for potential problems:

1. PMD from http://pmd.sourceforge.net/

License: PMD is licensed under a "BSD-style" license

PMD scans Java source code and looks for potential problems like:

* Possible bugs - empty try/catch/finally/switch statements
* Dead code - unused local variables, parameters and private methods
* Suboptimal code - wasteful String/StringBuffer usage
* Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
* Duplicate code - copied/pasted code means copied/pasted bugs

You can download everything from here, and you can get an overview of all the rules at the rulesets index page.

PMD is integrated with JDeveloper, Eclipse, JEdit, JBuilder, BlueJ, CodeGuide, NetBeans/Sun Java Studio Enterprise/Creator, IntelliJ IDEA, TextPad, Maven, Ant, Gel, JCreator, and Emacs.

2. FindBug from http://findbugs.sourceforge.net/

License: L-GPL

FindBugs, a program which uses static analysis to look for bugs in Java code. And since this is a project from my alumni university (IEEE - University of Maryland, College Park - Bill Pugh) , I have to definitely add this contribution to this list.

3. Clover from http://www.cenqua.com/clover/

License: Free for Open Source (more like a GPL)

Measures statement, method, and branch coverage and has XML, HTML, and GUI reporting. and comprehensive plug-ins for major IDEs.

* Improve Test Quality
* Increase Testing Productivity
* Keep Team on Track

Fully integrated plugins for NetBeans, Eclipse , IntelliJ IDEA, JBuilder and JDeveloper. These plugins allow you to measure and inspect coverage results without leaving the IDE.

Seamless Integration with projects using Apache Ant and Maven. * Easy integration into legacy build systems with command line interface and API.

Fast, accurate, configurable, detailed coverage reporting of Method, Statement, and Branch coverage.

Rich reporting in HTML, PDF, XML or a Swing GUI

Precise control over the coverage gathering with source-level filtering.

Historical charting of code coverage and other metrics.

Fully compatible with JUnit 3.x & 4.x, TestNG, JTiger and other testing frameworks. Can also be used with manual, functional or integration testing.

4. Macker from http://innig.net/macker/

License: GPL

Macker is a build-time architectural rule checking utility for Java developers. It's meant to model the architectural ideals programmers always dream up for their projects, and then break -- it helps keep code clean and consistent. You can tailor a rules file to suit a specific project's structure, or write some general "good practice" rules for your code. Macker doesn't try to shove anybody else's rules down your throat; it's flexible, and writing a rules file is part of the development process for each unique project.

5 EMMA from http://emma.sourceforge.net/

License: EMMA is distributed under the terms of Common Public License v1.0 and is thus free for both open-source and commercial development.

Reports on class, method, basic block, and line coverage (text, HTML, and XML).

EMMA can instrument classes for coverage either offline (before they are loaded) or on the fly (using an instrumenting application classloader).

Supported coverage types: class, method, line, basic block. EMMA can detect when a single source code line is covered only partially.

Coverage stats are aggregated at method, class, package, and "all classes" levels.

Output report types: plain text, HTML, XML. All report types support drill-down, to a user-controlled detail depth. The HTML report supports source code linking.

Output reports can highlight items with coverage levels below user-provided thresholds.

Coverage data obtained in different instrumentation or test runs can be merged together.

EMMA does not require access to the source code and degrades gracefully with decreasing amount of debug information available in the input classes.

EMMA can instrument individial .class files or entire .jars (in place, if desired). Efficient coverage subset filtering is possible, too.

Makefile and ANT build integration are supported on equal footing.

EMMA is quite fast: the runtime overhead of added instrumentation is small (5-20%) and the bytecode instrumentor itself is very fast (mostly limited by file I/O speed). Memory overhead is a few hundred bytes per Java class.

EMMA is 100% pure Java, has no external library dependencies, and works in any Java 2 JVM (even 1.2.x).

6. XRadar from http://xradar.sourceforge.net/

License: BSD (me thinks)

The XRadar is an open extensible code report tool currently supporting all Java based systems. The batch-processing framework produces HTML/SVG reports of the systems current state and the development over time - all presented in sexy tables and graphs.

The XRadar gives measurements on standard software metrics such as package metrics and dependencies, code size and complexity, code duplications, coding violations and code-style violations.

7. Hammurapi from Hammurapi Group

License: (if anyone knows the license for this email, let us know)

Hammurapi is a tool for execution of automated inspection of Java program code. Following the example of 282 rules of Hammurabi's code, we are offered over 120 Java classes, the so-called inspectors, which can, at three levels (source code, packages, repository of Java files), state whether the analysed source code contains violations of commonly accepted standards of coding.

Relevant Links:

http://en.sdjournal.org/products/articleInfo/93

http://wiki.hammurapi.biz/index.php?title=Hammurapi_4_Quick_Start

8. Relief from http://www.workingfrog.org/

License: GPL

Relief is a design tool providing a new look on Java projects. Relying on our ability to deal with real objects by examining their shape, size or relative place in space it gives a "physical" view on java packages, types and fields and their relationships, making them easier to handle.

9. Hudson from http://hudson-ci.org/

License: MIT

Hudson is a continuous integration (CI) tool written in Java, which runs in a servlet container, such as Apache Tomcat or the GlassFish application server. It supports SCM tools including CVS, Subversion, Git and Clearcase and can execute Apache Ant and Apache Maven based projects, as well as arbitrary shell scripts and Windows batch commands.

10. Cobertura from http://cobertura.sourceforge.net/

License: GNU GPL

Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. It is based on jcoverage.

11. SonarSource from http://www.sonarsource.org/ 

License: LGPL

Sonar is an open platform to manage code quality. As such, it covers the 7 axes of code quality:

Architecture & Design, Duplications, Unit Tests, Complexity, Potential bugs, Coding rules, Comments.

Feel free to suggest your own tools in the comments section.

Reference: Java Tools for Source Code Optimization and Analysis from our JCG partner at theOur Tech Stop blog.

Related Articles :

http://www.javacodegeeks.com/2011/07/java-tools-source-code-optimization-and.html

时间: 2024-10-27 20:22:45

Java Tools: Source Code Optimization and Analysis[转]的相关文章

EclipsePro: Java Tools for Professional Eclipse Developers

EclipseCon 2005 Special ReportEclipsePro: Java Tools for Professional Eclipse DevelopersEclipsePro software tools are specifically designed for professional Eclipse developers. EclipsePro Audit offers dynamic code audit and metrics capabilities. Ecli

Generate C interface from C++ source code using Clang libtooling

原文地址 Generate C interface from C++ source code using Clang libtooling Dec 6, 2016 · 24 minute read · Comments clangllvmCC++I developed a concurrent user-thread library using C++, and was looking for a way to provide a C interface and make the functio

Error:java: javacTask: source release 1.6 requires target release 1.6

IDEA运行web项目时报错: Error:Java: javacTask: source release 1.6 requires target release 1.6 解决方法:    

Coalesys.WebMenu source code(partial)(1)

web I post this source code in order to test our il2c#, this source code was generated by our software, this is the  "javascript" method of class Coalesys.WebMenu.Generate internal static void JavaScript(WebMenu webmenu, GenerateConstants type,

扩展UltraGrid控件实现对所有数据行的全选功能[Source Code下载]

在前面一篇文章中,我通过对三种Infragistics 控件(UltraToolBarManager.UltraGird和UltraListView)进行扩展,以实现对ToolTip样式的定义,今天我来介绍如何采用相同的方式实现另外一个更为常用的功能:在UltraGrid的Header中动态添加CheckBox,从而实现对所有数据行进行全选的功能.[Source Code从这里下载] 一.我们的目标:在UltraGird的选择列的Header添加CheckBox实现对所有数据行的全选  我们现有

java 如何根据 code 39 根据字体生成条码 ?

问题描述 java 如何根据 code 39 根据字体生成条码 ? 根绝code 39字体 生成条形码,不要以流的形式生成条形码图片,我希望的是根据字体生成出的条形码如有代码请附上,谢谢.

Enterprise Library Policy Injection Application Block 之三:PIAB的扩展—创建自定义CallHandler(提供Source Code下载)

本系列的第一部分对PIAB使用场景进行了简单的介绍,作中阐述了通过PI(Policy Injection)的方式实现了Business Logic和Non-Business Infrastructure Logic的分离,从而实现了AOP(Aspect Oriented Programming).在第二部分中详细介绍PIAB的实现机制:通过自定义RealProxy的方式实现了Method Injection.通过这几天接收到的网友的留言,觉得很多人对在具体的项目开发中如何使用PIAB还有很多困惑

事件(Event),绝大多数内存泄漏(Memory Leak)的元凶[下篇] (提供Source Code下载)

在上篇中我们谈到:将一个生命周期较短的对象(对象A)注册到一个生命周期较长(对象B)的某个事件(Event)上,两者便无形之间建立一个引用关系(B引用A).这种引用关系导致GC在进行垃圾回收的时候不会将A是为垃圾对象,最终使其常驻内存(或者说将A捆绑到B上,具有了和B一样的生命周期).这种让无用的对象不能被GC垃圾回收的现象,在托管环境下就是一种典型的内存泄漏问题.我们今天将会着重解释其背后的原因.[本篇文章的Source Code从这里下载) 一.CLR垃圾回收简介 在一个托管应用程序中,我们

android studio-Android Studio使用Source Code Pro字体全部乱码

问题描述 Android Studio使用Source Code Pro字体全部乱码 之前都是好好的,也可以使用Source Code Pro字体,不知道怎么了,这个字体全部都变成了乱码,字体删除了,但是Android Studio中依然有这个字体,重装软件也不行 ,最喜欢这个字体,别的字体看着不舒服,该怎么办 解决方案 https://segmentfault.com/q/1010000004182199