Together 6.3 for eclipse 3.0 is very useful. I spent some time reading the docs of the audits function, not all of which were translated and made some simple Chinese annotations. Paste it to share with you. Some of these terms provide guidance for our design and coding.
Array and reference of arrays and references
Accessing null reference (ANR) Access null reference
Array Index is out of range (aior) array subscript out of range
Array length is negative (AIN) array length is negative
Array length is too large (altl) array is too long
Maybe accessing null reference (manr) may access null references
Maybe array index is out of range (maior) array subscript may be out of range
Maybe array length is negative (maln) array length may be negative
Branches and loops branches and loops
Case label is unselectable (CLU) This case branch cannot be executed
Infinite Loop (IL) detects an infinite loop
Infinite recursion (IR) detects infinite Recursion
Label is not used (LNU) unused label
Loop body is executed exactly once (lbeeo) the loop body is actually executed only once
Loop body is never executed (lbne) the loop body is not actually executed
Statement is an unreachable (SU) statement that can never be executed
Coding styleCodeStyle
Switch statement shoshould include the default case (sssidc) where the switch statement should contain default
Accessing static members by the descendant Class Name (asmdcn) should not access the static members of the parent class through subclass (which class is used directly if it belongs)
Accessing static member through object (ASMO) should not access static members through objects (use classes directly)
Assignment to formal parameter (AFP) assigns values to parameters (which may be incorrect. Use temporary variables)
Complex assignment (CA) complex assignment
Complex initialization or update clause in for loop (ciucfl) complex initialization or update sub-statements in a loop
Declare List and set variables with the type of their interface (dlsv) try to use the list and set interfaces to define variables instead of specific types.
Long file (LF) try to avoid the file being too long (Sun conventions do not exceed 2000 lines)
Multiple statements on one line (msol) prevents multiple statements from being written in one line
Negation operator in If statement (NOIS) Try not to use non-operation in If statement (replace if else position)
Non-Final Static attribute (nfsa) should set static attributes to final as much as possible
Numerical literal in code (NLC) do not use numbers directly, instead of named Constants
Operator? : Shoshould not be used (osnbu) Try not to use? Operator
Parenthesize conditional expression in operator? : (PCO)? Enclose the conditional expression with parentheses during the operation
Place Constants on the same side of comparisons (pcss) Place Constants on the same side of the comparison operator
Place declaration at the beginning of block (pdbb) Place the declaration at the beginning of the statement Block
Provide incremental in for statement (PIFS) should provide increments in the for statement (otherwise, do not use the for Statement)
Referencing Implementation Package (RIP) references the implementation package (the interface package should be used whenever possible)
Restricted class declaration (RCD) closed class declaration (resulting in external access failure)
String Literal (SL) string hard encoding (use resource files whenever possible)
Temporary Variable is used for several purposes (tvusp) temporary variables are used for multiple purposes (as specific as possible)
Use this explicitly to access class members (UTE) use this to indicate that the class member is used
Use abbreviated assignment operator (uaao) to use short value assignment operations (for example, replacing a = a + I with a + = I)
Critical errors critical error
The command query separation query method (without changing the State) is not separated from the command method (changing the State) (to be accurately expressed)
The hiding inherited attribute subclass redefined the attributes of the parent class (the same attribute name is used)
The hiding inherited static method subclass redefined the static method of the parent class (using the same method name)
Inaccessible matching constructors or methods constructor or method that is difficult to match (similar parameter types are not easy to distinguish)
Index out of bounds subscript out of bounds
The invalid method call order is invalid (determined by the configuration file FSA. XML)
Invalid Type Cast or check invalid type forced conversion or check
Multiple visible declarations with the same name the visible property name and method name are the same (easy to misunderstand)
Overriding non-abstract method with abstract method overwrites non-abstract methods of the parent class into abstract methods.
Overriding private method overwrites the private method of the parent class
The overriding within subclass does not correctly override the parent class method, and the new method is overloaded.
Resource not found in boundle resource not found in resource package
Declaration style declaration Style
Abstract class declaration (ACD) checks the abstract class declaration (there is a problem if there is no abstract method or the constructor is public)
Always override object. hashcode () When you override object. Equals () (ohce) When overwriting equals (), it should also overwrite hascode ()
Avoid using universal exception specifiers (aues) avoids all-powerful exceptions and should use specific exceptions
Class shoshould be interface (CSI) This class can be made into an Interface
Conflict with system class (CWCs) naming conflicts with system class names
Constant private attribute shocould be final (cpasbf) Private constant attribute should be defined as final
Constant variable shocould be final (cvsbf) constant variable should be defined as final
Declare clone () throws clonenotsupportedexception for cloneable class (dcfc) to declare the clone () method throws clonenotsupportedexception
Declare variables in separate statements (dvss) Declare variables with separate statements
Define constant in Interface (DCI) defines constants in the interface (not defined in the class)
The hidden name (HN) may mistakenly use the member variable.
Incorrect main () method declaration (immd) "Incorrect main () method declaration (generally
Public static void main (string [])"
Inner class does not use outer class (inuo) embedded classes do not use external classes (in this case, we recommend that you declare the embedded class as static)
Instantiated class shoshould be final (icsbf) This suggests that all classes that can be instantiated should be declared as final (without flexibility)
Member can be made private (MCP) members can be declared as private
Non-static method does not use instance variables (mnui) non-static methods do not use instance variables (you can declare the method as static)
Order of declaration of class members (odcm) class member sequence (generally: Class (static) variable, instance variable, constructor, other methods, in the order of Public-> protect-> package-> private)
Place operations with same name together (posnt) Put operations with the same name together
Place public class first (ppcf) Place the public class at the beginning
Serializable class declaration (SCD) whether the serializable class declaration is correct (when the serializable class does not contain the non-static and non-transient fields, A warning is given when the inherited parent class is non-serializable and has no accessible parameter-free constructor)
The Utility Class Declaration (UCD) tool class declaration should set the constructor to private
Design by contract contractual design
Design by contract condition violation (dbcv) Violation of contractual design
Design flaws design defects
Data class (DC) data class (class that lacks behavior and is heavily dependent on other classes)
Data clump (DCL) Data bundle (data and operations can be split into different classes)
Feature envy (FE) feature envy (some methods are actually more interested in the data of another class, meaning this method may be put in the wrong place)
Field is used as temporary variable (futv) is used as a temporary variable
God class (GC) God class (almost omnipotent class)
God method (GM) GOD method (similar to God)
God package (GP) God package (contains a multi-function package that puts a burden on reuse)
ISP violation (ispv) violates the interface separation principle (as far as possible, it does not define too many functions in an interface)
The long message chain (LMC) delegate method constitutes a too long message chain (Class A's a method calls Class B's a method, class B's a method calls Class C's a method, so proceed)
Member is used by only one subclass (muos) members of the parent class are only used by some of the Child classes (no universality, should be put down to the Child class)
Misplaced class (MC) may be the class that is mistakenly put in the bag of God
Refused bequest (RB) rejects inheritance (rejecting the data or methods of the parent class, which may be because the class relationship is not well designed)
Shotgun surgery)
Subclasses differ only in Methods returning constant values (sdmc) each subclass has a difference only when the constant value returned by the method is different.
Subclasses have the same Member (SSM) each subclass has the same Member (should be placed in the parent class)
Suspicious switch statement usage (SSU) always suspects the use of the switch statement (switch is often a product of the process-oriented, so we should try to remove the switch statement using the object-oriented method)
Use interface instead of implementation (uiii) use interfaces instead of specific implementations (following interface-based programming principles)
Use Singleton pattern (USP) uses the single-instance mode (for classes with only static variables, consider using the single-instance mode and exposing only one static method to obtain the instance, other methods are not static)
Wide subsystem interface (lack of facade) (WSI) Too many subsystem interfaces (lack of appearance, should use appearance mode integration)
Documentation document
Bad tag in javadoc comments (btjc) has bad labels in javadoc annotations
Provide file comment (PFC) provides file comments (Sun conventions)
Provide javadoc comment (pjdc) provides javadoc comments (Sun conventions)
Duplicate duplicated code
Duplicate duplicated code (DC)
Duplicated code in conditional branches (DCCB) duplicate code exists in the condition Branch
Duplicated code in Constructors (DCC) has repeated code in the constructor.
Expressions expression
the argument value is invalid (AVI) parameter value is invalid
comparison always produces the same result (CSR) comparison always returns the same value (redundant comparison)
data is lost in result of type conversion (DL) type conversion causes data loss (when a large integer is converted to a small integer)
disjoint bit masks (DBM) Non-Intersecting bit masks (avoiding comparison of bit operation expressions)
division by zero (dbz) Division by zero (arithmeticexception is thrown during runtime)
expression value is always zero (evaz) expression value is always zero
expression value is constant (EVC) the expression value is a constant.
expression value is not used (evnu) the expression value is not used.
expression value is floating-point infinity or Nan (FIN) the expression value is an infinite floating point number or a number.
integer division in floating-point context (idfc) integer Division in floating point content (unexpected integer rather than floating point value)
integer overflow or underflow (IOU) integer Overflow or underflow (note the range similar to int or long values)
maybe data is lost in result of type conversion (MDL) data may be lost after type conversion
maybe shift count is out of range (mscor) shift count may be out of range
operation has no effect (one) no affected operation (additional operation)
shift count is out of range (SCOR) shift count out of range (OK)
Metric violations violation statistics
Metric violation (MV) is combined with togetherec's metric function (very powerful, very fine statistics)
Naming Style
Class Name shocould match file name (cnsmfn) class name should match the file name
Name of exception class (NEC) Exception name should end with exception
Naming Conventions (NC) Naming Convention (class or interface name starts with uppercase, method, field, variable name starts with lowercase, constant should all uppercase, etc)
Package name (PN) The package name should start with a domain name (COM, org, etc.) or country code (CN, Ru, etc.)
Use conventional variable names (ucvn) using the agreed variable name
Performance
appending to string within loop accumulates strings in a loop (instead of stringbuffer)
avoid using 'new' keyword when creating string objects to hold string literal avoid using new to create a String object (use a string directly)
complex loop expression avoid using complex expressions in a loop
declaring variables inside loops avoid declaring variables in a loop
duplicated Type Cast repeated Type forced conversion
inefficient conversion inefficient conversion (using integer. parseint (s) instead of integer. valueof (s ). intvalue (), using integer. tostring (I) instead of new INTEGER (I ). tostring ()
multiple string concatenations avoid concatenating multiple strings (instead of stringbuffer)
replace nested if-else statements with switch replace nested if-else with switch
store returned value in local variable to avoid storing returned values in local variables
too records too many switch conditions in switch statement cases
Portability portability
Avoid hard-coded '/N' or'/R' as line separator avoid using/N or/R hard encoding into line breaks (using system. getproperty ("line. separator)
Avoid using 'java. AWT. Peer. * 'Package avoid using Java. AWT. Perr. * package (only inside AWT)
Avoid using user-defined native methods avoid using custom native Methods
Identifier conflicts with keyword uses the identifier that conflicts with the keyword (including the package name, which may cause conflicts: const, Delegate, Enum, Goto, internal, template, virtual)
Implementation of system interface avoid implementing system-level interfaces (such as interfaces in the Java. SQL package)
Non-portable call avoids unportable calls (for example, system. getenv (), instead of system. getproperty)
Possible Errors of possible errors
Assignment in conditional expression value in the condition expression
Assignment to 'for' loop variable assigns a value to the variable in
Break statement is missing before case clause case without a break statement (unless otherwise specified, add a comment)
Calling abstract method from constructor in abstract class the abstract method is called in the constructor)
Comparing floating-point values: Comparison of floating point values (less =)
Comparison of short with Char compares short and char directly (Compare short & 0xffff before)
Constants with equal values has multiple constants with the same value
Contradictory operation with container class performs wrong operations on the container (for example, put it into a point, but cast it into line after removal)
Contradictory type cast or check error Type Cast and check
Discordant usage of cast operator and check of returned value of qualificator method check cast errors caused by incorrect use of type code
Discordant usage of 'instanceof 'and cast operators instanceof are inconsistent with cast operations.
Empty Catch Block empty Catch Block
Enumeration constant is not handled in switch statement enumeration constant not all processed by Switch
Explicit call to 'finalize () 'Call finalize ()
Explicitly Initialize all variables as much as possible
Heterogeneous container do not place different types of objects in the same container
Incompatible enumeration types usage does not use enumeration constants consistently
The finalize () method of the incorrect 'finalize () 'method is incorrect. The finalize () method has only one form and needs to call Super. Finalize ())
Incorrect array copy incorrect array copy (check whether system. arraycopy () is used correctly)
Iteration variable is not used in loop body iteration variable is not used in the loop
Maybe incorrect enumeration definition may be an incorrect enumeration definition (repeated values can be analyzed or there is no constant definition by sequence)
Maybe wrong assumption about operator precedence may be incorrect, assuming the operator priority
Method is not overriden by mistyping may be incorrect or there is no overload method
Misplaced argument position may have the wrong parameter location (you can find the parameter when the parameter name is the same as the actual parameter name)
Mixing logical operators without parentheses may not be enclosed in brackets or may have a logic error
Non-case label in switch statement is missing case in the switch statement, leading to incorrect label
Non-constructor method with the same name as declaring class indicates the method name with the same name as the constructor method.
Object may be not finalized object may not be released (not in the Finally block)
Operation has suspicious side effects operation may have side effects
Place statement in block should place the statement in the block (use {})
Possible integer overflow before conversion to long int conversion may overflow
Public and package attributes exposure attributes (poor encapsulation)
Replace inequality comparison with equality comparison replace greater than or less
Socket Io problems socket Io Problems
Statement with empty body statement with no content
Static attribute used for initialization non-final static attribute should not be used for initialization
Suspicious break/Continue may be incorrect break/continue
Suspicious for statement may be incorrect
Use 'l' instead of 'l' at the end of Integer constants to represent an integer constant. Use uppercase L instead of lowercase L.
Use 'eques' instead of '=' try to use equals instead of =
Excess superfluous content
Empty synchronized statement or finally block (ESF) is an empty statement or a Finally block.
Equality operations on Boolean arguments (eoba) "Avoid equal Comparison on Boolean parameters (use or use directly! To determine)
For example, replace success = false! Success"
Exception declared in throws clause is never thrown (ENT) throws declared exceptions will never be thrown
Import List construction (ILC) Repeated introduction (introduced)
Member is not used (MNU) not used Member
Obsolete interface modifier (OIM) Obsolete interface modifier (Abstract modifier is not recommended)
Return value is not used (rvnu) return value never used
Unnecessary member modifier (UMM) unnecessary member Modifier
Unnecessary Return Statement parentheses (ursp) Extra Return Statement parentheses
Unnecessary Type Cast (UC) redundant type forced conversion
Unused local variable or formal parameter (ulvfp) unused local variables or parameters
Synchronization
Avoid using thread_sleep () (AUS) the thread that calls thread. Sleep () cannot be restored unless the sleep expires. We recommend that you use object. Wait () instead.
The behavior of avoid using thread_yield () (auy) thread. Yield () method is heavily dependent on the multithreading model. This method should be avoided.
Field is accessed concurrently with Different lock sets (fadls) may be caused by the use of different locks and some domains do not control synchronous access
Field is accessed concurrently without locking (fawl) does not use a lock and some domains do not control synchronous access.
Locking monitor can cause deadlock (lmccd) can cause locking monitor deadlocks
Method wait () can be invoked with monitor of other object locked (mwiml) method wait () may be called after being locked by another object's monitor. This causes the actual object to be suspended or delayed. (The wait operation will discard the CPU time suspension thread)
Non-synchronized access to class (NSAC) Non-synchronous access to the class (for those non-thread-safe classes)
Synchronized attribute is not needed (Sann) redundant synchronized
Synchronized Method is overridden by non-Synchronized Method (smons) synchronous method is overwritten as non-synchronous method
Synchronized modifier (SM) tries its best to use synchronization blocks instead of the entire synchronization method.
Wait or notification method is called from non-Synchronized Method (nmcnsm) waiting or notification methods are called through non-synchronous methods (runtime errors ).