Code Review Checklist Review

Source: Internet
Author: User
Tags bug id

Code Review Checklist

General items

    • Can the code work? It has not implemented the expected function, the logic is correct and so on.
    • Is all the code easy to understand?
    • Does the code conform to the programming specifications you follow? This usually includes the position of the curly brace, the variable name and function name, the length of the line, the indentation, the format, and the comment.
    • Are there redundant or duplicated code?
    • is the code as modular as possible?
    • Is there a global variable that can be replaced?
    • Is there any code that is commented out?
    • Does the loop set the length and correct termination conditions?
    • Is there a code that can be substituted by the library function?
    • Is there a log or debug code that can be deleted?

Safety

    • Are all data inputs checked (detection of the correct type, length, format, and range) and encoded?
    • Where are the third-party tools used, and are the returned errors captured?
    • Is the value of the output checked and encoded?
    • Can invalid parameter values be handled?

Document

    • Is there a comment and describes the intent of the code?
    • Do all the functions have comments?
    • Is there a description of unconventional behavior and boundary condition handling?
    • Is there a document for the use and function of the third party libraries?
    • is the data structure and unit of measurement explained?
    • Is there a code that is not completed? If so, should it be removed, or tagged with the appropriate tags such as ' TODO '?

Test

    • Can the code be tested? For example, do not add too many or hidden dependencies, cannot initialize objects, test frameworks can use methods, and so on.
    • Are there tests that can be understood? For example, reach at least the code coverage you are satisfied with.
    • Does the unit test really test that the code can do the expected functionality?
    • Did you check the "Out of Bounds" error of the array?
    • Is there a test code that can be replaced by an already existing API?
Optimize your Inventory

Use the list as your starting point, and you need to optimize it for specific use cases. A great way to do this is to have your team record the issues that were discovered temporarily during the code review process, and with this data, you can identify the errors that your team often makes, and then you can tailor a review checklist. Make sure you remove any errors that have not occurred. (You can also keep items that are very small, but very critical, such as security-related issues).

be recognized and kept up to date

The basic rule is that any entry on the list must be clear and, if possible, you can make a two-dollar decision on some items. This prevents inconsistencies in judgment. It's a good idea to share this list with your team and make them agree with your list. Similarly, check your list regularly to make sure that the entries are still meaningful.

With a good list, you can increase the number of bugs you find in the code review process. This can help you improve your code standards and avoid the uneven quality of code reviews.

Divider Line

Java Code Review Checklist

Code reviews can help improve code quality and avoid bugs caused by code habits. The key points listed below can be used as a guideline for most code reviews, and should be considered best practices if they are Java applications.

Document

1. Javadoc should be added in each of the classes and methods.

2. If you are fixing a bug, you should add a bug ID.

3. The way to take shortcuts or complex logic should be explained.

4. If the code is exposed, each file header should be labeled with copyright information.

5. Complex html,javascript,css should contain documentation.

Function

1. If a similar logic is used more than once, it should be written as a helper class and then called in more than one.

2. Encourage the use of APIs instead of repeating code to solve the same problem.

3. To emphasize unit testing of the code.

4. Any newly added code should not break existing code.

5. If it is a WEB application, the JSP should not contain Java code.

Safety

1. No code can perform user input unless escaped. This often contains the Eval function and SQL statement for JavaScript.

2. Prohibit IP that submits very many requests in a short period of time.

3. Any class, variable, or method should have the correct access domain.

4. Try to avoid using an IFRAME.

Performance

1. All database and file handlers should be closed when they are not needed.

2. The writing of SQL statements can result in vastly varying performance.

3. Encourage the creation of immutable (immutable) classes.

4. Similar logic code, as far as possible through the IF else statement to achieve more reuse.

5. Try to avoid using heavy objects (heavy objects).

6. If it is a Web project, please check whether the appropriate image size, CSS sprites and browser caching techniques are used.

7. The information required in the global context is kept in application.

Coding habits

1. The variable to be deleted is not used.

2. For different Exception, use different catch statements instead of a Exception to solve all the problems.

3. For variables, methods and classes should use the same naming method.

4. Constants should be written in a separate constant class.

5. Do not have extra spaces at the end of each line of code.

6. For parentheses, loops, if statements, etc., use a uniform format.

7. Each individual method should not exceed 100 lines.

8. A single statement should not exceed the viewable area of the editor, and it can be split into several lines.

9. The best way to check if a String object is neither null nor empty is if ("". Equals (str))

10. If a class has many member variables, and it requires only a few variables to be instantiated, it is best to use the static factory method instead of overloading the constructor.

11. Add the appropriate access control to the method, not all public.

12. Follow best practice recommendations for the framework used in the project, such as Spring,struts,hibernate,jquery.

Some of these points of attention can be done through static code checking tools, such as Checkstyle,findbugs and JTest.

Code Review Checklist Review

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.