Java Developer Tools

Audit - Rules - Comments

Description
This group contains audit rules that look for the correct usage of non-Javadoc comments within your code.

Rules:

Details

Code in Comments

Summary
Code that has been commented-out should be removed.

Description
This rule searches for comments that appear to contain code and flags them. Such code should either be removed or made conditional (for example, by testing a logging level).

Example
The following comment would be flagged:

    //System.out.println("Entering method");

Comment Local Variables

Summary
Local variables should be commented.

Description
This audit rule checks for local variable declarations that are not followed by an end-of-line style comment. The comment is intended to describe the purpose of the variable.

If there are multiple local variables declared on a single line, the comment (if there is one) is assumed to belong to the first variable.

Example
The following local variable declaration would be flagged because it is not commented:

    int sum = 0;

Document Closing Braces

Summary
Closing braces should be documented with a comment.

Description
This audit rule checks for closing braces for specified statements that are not followed by a specified end-of-line comment. The comments are used to make it easier for readers to see the structure of the code.

Example
The closing brace for the following if statement would be flagged as needing to be commented:

    if (employee.isHourly()) {
        ...
    }

File Comment

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.