Javabugchecker1.0 (Java source code error checking tool)

Source: Internet
Author: User

Source code (Java project) download: http://code.google.com/p/java-parser-executor/downloads/list (deprecated !)

This article is out of date and is not recommended for reading.

Many minor diseases are intertwined and become serious. -- The Code will also get sick.

 

There are a lot of simple errors in daily coding. I try to automate these errors as much as possible (programmers should not be physical workers ).
Java source code error check application scope:
1. Eliminate the logic errors of the Code.
For example, using a variable that does not have a "relationship" with the array as a member subscript is a common type of code input error.
The unreasonable nature of the Code in "process logic" is common.
2. Normative check of source code comments.
3. Normative check of source code.
A. The process statement must have a block. For example, for (...) A = 2; no block.
B. disable unnecessary permanent false value entries. For example, if (true )...
C. Minimize the accessibility of class attributes and methods. For example, change public to non-public.
D. Remove redundant methods or code. In practice, many methods are not used after being attempted. This is also true for partial code blocks.
E. Do not use magic numbers.
F. Others.
4. Check the relationship between source code and related resources.
For example, the content in the hibernate configuration file is mapped to the source code. We can try to define and detect such a relationship.

5. In addition, source code errors can be used for programming in other languages, scripts, and SQL errors.

  
Common Code errors:

1. variable name conflict
For example: int age, weight;...; age = weight;
The weight can also be assigned to the age, which is obviously incorrect.
2. the unused value is overwritten.
For example, in the code "int A = 2; B = C; A = B;", the number 2 is not used.
3. invalid value
For example: String file = "C:/film/a.txt"; new file (File); this file obviously does not exist.
4. The variable link is abnormal.
For example, use a variable that has not "relation" with the array as the member subscript of the array.
5. Isolated Code blocks.
Some Code does not have any impact on the runtime system. In fact, this is a common error.
6. Regular Expression exception.
For example, String. replaceall ("ABC", "def"); It should be optimized to string. Replace ("ABC", "def ");
Some static and simple error modes can be described using regular expressions.
7. Logic exception.
For example, if (A> B) {...} else if (a <B) {...} elseif (A = B) {...} else {logical redundancy}
Redundant, unreasonable, and permanent false procedures should be optimized. The Automatic Optimization of mathematical logic is theoretically mature (unconfirmed ).
8. Other exceptions.
Generic exceptions.

 

 

Procedure:
1. Import this project in Eclipse IDE, with JRE "1.6.0 _ 10" or above.

2. properly set the value of 'Project _ root' in file:
/Javabugchecker1.0.0/SRCS/sample/demo/configofbugchecker.txt

3. Run testcase: "/javabugchecker1.0.0/SRCS/sample/demo/basicbugcheckertestcase. Java ".
Bug list will print to the console.

4. Click the hyperlink in the print list, it brings you to the bug location.

2010-3-25

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.