Three tools for easy and effective inspection of Java code: PMD, Checkstyle, and Jalopy

Source: Internet
Author: User
Tags checkstyle

PMD and Checkstyle

Depending on the PMD document, it checks the following sections in your code:

Unused local variables
An empty catch block
Parameter not used
Empty if statement
Duplicate import statement
Unused private methods
Could be a singletons class.
Short/Long variable and method name
Checkstyle Check the following sections:

Javadoc annotation
Naming conventions
Import statement
Volume size
Mixed Check (pack live some useful, such as System.out and Printstacktrace)

their role

Pmd,checkstyle can check Javadoc annotations; But PMD provides a useful feature called CPD, which checks the copy-and-paste portion of the code. The most frequent errors I have found using PMD are unused import statements, unused private variables, and unexpected repeat spelling. Checkstyle can find more errors. Includes a missing Javadoc annotation, more than 80-character lines, an inconsistent variable name, a tab instead of a space, and so on. All two tools allow you to create custom rules.

If you want to use one of them in your organization, Checkstyle seems better: it checks most of the projects agreed by the company code. If improving code quality is the primary goal, then PMD is a good choice. But if you want more features and really use tools to modify the code, you should try jalopy.

jalopy, Jalopy is an easy to configure source code format program that detects and fixes a large number of custom bugs in Java code. Jalopy is more like a code-builder than an inspector. Jalopy's plug-ins now support most Ides, and most are seamless integration. I find that jalopy is particularly powerful and can do a lot of cool things. For example, it can modify code indentation, align parentheses, make line widths conform to a character length, insert related Javadoc annotations, and sort import statements. The best place to Jalopy is the Super customization feature. A simple user interface allows you to select all the features of the jalopy switch without requiring an XML configuration file.

Don't waste resources
I suggest that you use these tools instead of time-consuming and laborious manual code checks. Once you've used these tools to turn code checking into a relatively easy task, you can check your code as a common job rather than a mess at the end of the project. These tools also provide an integration with Apache ant, so you can run these code inspectors every day, and they can work well when compiling or executing unit tests. Control your code and deliver what you really think is high quality.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.