FindBugs Introduction (Eclipse Installation usage instance)

Source: Internet
Author: User

General companies will have some development specifications, but in fact, simply look at that one or two times can not develop the habit, or to remember these norms. In particular, for some novices, writing code is often bad. Look back at the code you wrote a year or two ago and you'll know what it's like to be "bad".

With some testing tools, the control of code quality is effective. FindBugs is a good tool for this kind of thing.

I. Introduction of FINDBUGS

FindBugs is a static analysis tool that examines a class or JAR file to compare bytecode with a set of defect patterns to identify possible problems. With the static analysis tool, you can analyze the software without actually running the program.

In short, FindBugs is a program that looks for bugs in a Java program that looks for instances of the bug pattern, which is the code instance that could be faulted. FindBugs is to check the Java bytecode, which is the *.class file.

In fact, it is to look for code defects, many of the bad places we write, can be optimized, it can be checked out.

For example: Database connection not closed, missing necessary null check, extra null check, redundant if post condition, same conditional branch, duplicate code block, wrong use of "= =", use StringBuffer instead of string plus and so on.

And we can also configure the check rules ourselves (what checks, do not check), you can also implement the unique validation rules (user-specific bug patterns need to inherit its interface, write their own check class, is an advanced technique).

Of course, FindBugs is just a tool. As a developer, of course, the first thing to do is to try to avoid introducing bugs when programming, rather than relying on a tool to check for yourself. But because of the complexity of the code, some of the hidden bugs are really hard to find with our naked eye. At this point, the application of some good tools may help you to find such a bug. This is the value of the existence of Fingbug.

The static analysis tool promises to find flaws in the code without the developer's effort. Of course, if you have many years of writing experience, you will know that these commitments are not guaranteed to be fulfilled.

One of the problems with the code quality tools is that they provide developers with a lot of but not a real problem-the pseudo-problem (false positives).

Ii. installation of findbugs in eclipse

In fact, most of the Eclipse plug-ins are basically similar to how they are installed. There are only two, download the corresponding plug-in offline installation and "Help" –> "Install New Software" installation. The first offline installation is relatively fast.

(1) Offline Installation:

Download 20131115123549_nlpir_ictclas2013_u20131115_ to http://findbugs.sourceforge.net/downloads.html Release.zip, extract the extracted edu.umd.cs.findbugs.plugin.eclipse_3.0.1.20150306-5afe4d1 directly into the eclipse's plugins directory, You can then restart Eclipse.

Note that the requirements here are eclipse3.6 and above, it is said that apes basically can keep up with the trend. You can check under your own Eclipse version confirmation (help->about Eclipse)

The Little Pigeon is 4.4.2 version

(2) Online installation

Click "Help->installnew Software", such as:

Then

Name "Enter" FindBugs "," Location "enter" Http://findbugs.cs.umd.edu/eclipse "as follows:

Then select the corresponding plugin as follows:

The following is the next step, the next step can be, online installation may need to wait for a long time, patience, do not interrupt!

You will be prompted to restart Eclipse later, and you can use it after rebooting.

Iii. use of findbugs in eclipse

(1) After the installation is complete and restarted, select an item, right-click, select Find Bugs:

(2) View the Bug Explorer view when the operation is complete, if there is no view, such as:

(3) If you check out your code problems will appear as:

(4) Click on one of the leaf nodes:

Is the small Bao intentionally added null pointer problem.

Other more use features just wait for the ape friends to learn more. Because blogging really takes more time ~ ~ ~

FindBugs Introduction (Eclipse Installation usage instance)

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: info-contact@alibabacloud.com 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.