Introduction to the Java Code Static analysis tool in the Eclipse environment __java

Source: Internet
Author: User
Tags checkstyle

There are a lot of plug-ins in the eclipse environment that can help us with the static analysis of the code, which can help us find bugs in the code as early as possible. Here are a few common plug-ins:

1. PMD

We can install the PMD plug-in for eclipse through Http://

PMD is a Java source Code analysis tool based on static rules. It comes with some rules that can be used directly, and users can define their own rules to check for potential problems with Java code: Possible bugs-such as empty TRY/CATCH/FINALLY/SWITCH statement block useless code-such as local variables not used, parameters and private methods Empty if/while expressions are overly complex expressions-such as unnecessary if,for loops can be used directly with the while loop suboptimal code-for example, String/stringbuffer's improper use class has too much complexity to duplicate the code

Of course, the problem that PMD finds may not be a real bug, it needs to be judged by yourself.

2. Checkstyle

Checkstyle Plugin Installation Address Http://
For more detailed information, refer to

Checkstyle is also a rule-based Java code Static Analysis tool for better quality, readability, and reusability of Java code. Checkstyle defines the degree of rigor that can be configured, and each of its rules has corresponding notifications, warnings, and errors. Its check analysis features include: Java code annotation naming specification method parameters number, the length of each line of code in the code of the Space class when constructing the way to duplicate code complex code

In actual use, you will find that Checkstyle check out a lot of problems, you can choose according to the needs.

3. FindBugs

Checkstyle Plugin Installation Address

For more detailed information, refer to

As the name suggests, FindBugs is a tool to help us analyze bugs in the code, but unlike the two tools above, it is discovering the problem by matching the code's bytecode (class file) and a set of bug patterns. That is, FindBugs does not pay attention to style or format, it tries to find only real flaws or potential performance problems, such as: Hash equals mismatched null pointers before detection initialization read fields

In the actual development process, the personal thought of practical degree: FindBugs > PMD > Checkstyle

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.