Preliminary study on FindBugs

Source: Internet
Author: User

1. What is 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. Rather than determining the intent of a program by parsing the form or structure of a class file, it is common to use the Visitor pattern to identify whether the code conforms to some fixed specifications.
FindBugs is an open source Eclipse Code Checker, which helps us to discover the bug,bad smell and potential pitfalls that exist in program code in a simple and efficient manner. For various problems, it also provides a simple modification of the comments for us to reconstruct the reference, by using it, can reduce the workload of our code review to some extent, and will improve the efficiency of review. Through FindBugs to find bugs, and then by our own refactoring code, we can cultivate our coding awareness and level, the formation of good habits to improve the development of coding ability.
2. How to install FindBugs
As a plug-in for Eclipse, you can integrate FindBugs into eclipse.
The first is an online installation: Enter http://findbugs.cs.umd.edu/eclipse in the plug-in installation address of Eclipse and "next" to install successfully.
The second way is to download the FindBugs plugin, put it into the Plusin folder under Eclipse, and then restart Eclipse.
To install the FindBugs plugin:
  1. In Eclipse, click to Help, software Update , Find and Install ...
  2. Choose the Search for new features to install option, and click Next.
  3. Click New Remote Site.
  4. Sites to include in Search .  click the checkbox next to it to select it, and click  Finish .
    • name:  FindBugs Update site
    • url:  one of the following (no Te:no final slash on the URL)
      • http://findbugs.cs.umd.edu/eclipse  for official Relea SES
      • http://findbugs.cs.umd.edu/eclipse-candidate  for candidate releases and official Releases
      • http://findbugs.cs.umd.edu/eclipse-daily  for all releases, including Developmental ones
    and click  OK .
  5. You should see FindBugs Feature under Select features to install.
    (You could have to click on one or both triangles to make it visible in the tree.)
    Select the checkbox next to it and click Next.
  6. Select the I accept option to accept the license and click Next.
  7. Make sure the location is correct where you ' re installing it. The default (your workspace) should be fine. Click Finish.
  8. The plugin is not digitally signed. Go ahead and install it anyway.
  9. Click Yes to make Eclipse restart itself.
3. How to use FindBugs
After installing the FindBugs plugin. Right click on the item you want to check select "Find Bugs", "Find Bugs" to check. To see what Bugs findbugs checked out, you can open the Bug Explorer panel by choosing Windows menu->show View->bug Explorer. If you want to see detailed information about a bug, you can choose the Windows menu->open perspective, and then select FindBugs to open the Properties panel for FindBugs. In this panel you can see the most detailed bugs information.
1, in Eclipse package Explorer, right-select target Project-build project
2, select the specified package or class for Findbug, at which time FindBugs will traverse the specified package or class, parse it, find out the code bug, and then focus on the Bugs Explorer in Find bugs, and add Bugs Explorer below.
3, adding FindBugs Explorer
(lower left corner of Eclipse)
4, after Bugs Explorer is added, we can view the bugs we just found.
4. All bug types FindBugs can find

FindBugs website http://findbugs.sourceforge.net/bugDescriptions.html provides a complete list of types.
The bugs identified are 3 colors, the black bug mark is classified, and the red bug indicates that the code must be modified after a serious bug is found, and the orange bug indicates a potential warning bug to try to modify. (appendix is a variety of bug interpretation and modification of the scheme, please refer to the schedule for revision)
Double-click the bug item to automatically open the relevant code file and connect to the code snippet in the edit window on the right. Clicking on the little bug icon next to the line number will provide a detailed description of the bug, as well as suggestions for changes, in the output area below eclipse. We can make changes based on this information.

Reprint Address: http://beee.iteye.com/blog/1470698

Preliminary study on FindBugs

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.