– Rule changed: SingularField changed its ruleset from controversial to design
– Rule removed: AvoidNonConstructorMethodsWithClassName
– Rules added (name, category, description):
In basic ruleset :
- AvoidUsingHardCodedIP, Portability, "An application with hard coded IP may become impossible to deploy in some case. It never hurts to externalize IP adresses."
- CheckResultSet, Usability, Always check the return of one of the navigation method (next,previous,first,last) of a ResultSet. Indeed, if the value return is "false", the developer should deal with it !"
In controversial ruleset:
- AvoidUsingShortType, Efficiency, "Java uses the short type to reduce memory usage, not to optimize calculation. On the contrary, the jvm does not has an arithmetic capabilities with the type short. So, the P-code must convert the short into int, then do the proper caculation and then again, convert int to short. So, use of the "short" type may have a great effect on memory usage."
- AvoidUsingVolatile, Maintanability, "Use of the keyword "volatile" is general used to fine tune a Java application, and therefore, requires a good expertise of the Java Memory Model. Morover, its range of action is somewhat misknown. Therefore, the volatile keyword should not be used for maintenance purpose and portability."
- AvoidUsingNativeCode, Portability, "As JVM and Java language offer already many help in creating application, it should be very rare to have to rely on non-java code. Even though, it is rare to actually have to use Java Native Interface (JNI). As the use of JNI make application less portable, and harder to maintain, it is not recommended."
- AvoidAccessibilityAlteration, Usability, "Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(), as the interface PrivilegedAction, allow to alter, at runtime, the visilibilty of variable, classes, or methods, even if they are private. Obviously, no one should do so, as such behavior is against everything encapsulation principal stands for."
In design ruleset:
- EmptyMethodInAbstractClassShouldBeAbstract, Usability, "An empty method in an abstract class should be abstract instead, as developer may rely on this empty implementation rather than code the appropriate one."
In import ruleset:
- TooManyStaticImports, Maintanability, "If you overuse the static import feature, it can make your program unreadable and unmaintainable, polluting its namespace with all the static members you import. Readers of your code (including you, a few months after you wrote it) will not know which class a static member comes from (Sun 1.5 Language Guide)."
In j2ee ruleset:
- DoNotCallSystemExit, Usability, "Web applications should not call System.exit(), since only the web container or the application server should stop the JVM."
- StaticEJBFieldShouldBeFinal, Usability, "According to the J2EE specification (p.494), an EJB should not have any static fields with write access. However, static read only fields are allowed. This ensures proper behavior especially when instances are distributed by the container on several JREs."
- DoNotUseThreads, Usability, The J2EE specification explicitly forbid use of threads.
- MDBAndSessionBeanNamingConvention, Usability, The EJB Specification state that any MessageDrivenBean or SessionBean should be suffixed by Bean.
- RemoteSessionInterfaceNamingConvention, Usability, "Remote Home interface of a Session EJB should be suffixed by "Home".
- LocalInterfaceSessionNamingConvention, Usability, "The Local Interface of a Session EJB should be suffixed by "Local"."
- LocalHomeNamingConvention, Usability, "The Local Home interface of a Session EJB should be suffixed by "LocalHome"."
- RemoteInterfaceNamingConvention, Usability,"Remote Interface of a Session EJB should NOT be suffixed."
In strings ruleset:
- UseEqualsToCompareStrings, Usability, "Using "==" or "!=" to compare strings only works if intern version is used on both sides."
In strictexception ruleset:
- DoNotExtendJavaLangError, Usability, "Errors are system exceptions. Do not extend them."
In optimizations ruleset:
- AddEmptyString, Efficiency, "Finds empty string literals which are being added. This is an inefficient way to convert any type to a String."
In naming ruleset:
- BooleanGetMethodName, Usability, "Looks for methods named "getX()" with "boolean" as the return type. The convention is to name these methods "isX()"."
– Rule changed: SingularField changed its ruleset from controversial to design
– Rule removed: AvoidNonConstructorMethodsWithClassName
– Rules added (name, category, description):
In basic ruleset :
In controversial ruleset:
In design ruleset:
In import ruleset:
In j2ee ruleset:
In strings ruleset:
In strictexception ruleset:
In optimizations ruleset:
In naming ruleset:
- AvoidUsingHardCodedIP, Portability, "An application with hard coded IP may become impossible to deploy in some case. It never hurts to externalize IP adresses."
- CheckResultSet, Usability, Always check the return of one of the navigation method (next,previous,first,last) of a ResultSet. Indeed, if the value return is "false", the developer should deal with it !"
In controversial ruleset:- AvoidUsingShortType, Efficiency, "Java uses the short type to reduce memory usage, not to optimize calculation. On the contrary, the jvm does not has an arithmetic capabilities with the type short. So, the P-code must convert the short into int, then do the proper caculation and then again, convert int to short. So, use of the "short" type may have a great effect on memory usage."
- AvoidUsingVolatile, Maintanability, "Use of the keyword "volatile" is general used to fine tune a Java application, and therefore, requires a good expertise of the Java Memory Model. Morover, its range of action is somewhat misknown. Therefore, the volatile keyword should not be used for maintenance purpose and portability."
- AvoidUsingNativeCode, Portability, "As JVM and Java language offer already many help in creating application, it should be very rare to have to rely on non-java code. Even though, it is rare to actually have to use Java Native Interface (JNI). As the use of JNI make application less portable, and harder to maintain, it is not recommended."
- AvoidAccessibilityAlteration, Usability, "Methods such as getDeclaredConstructors(), getDeclaredConstructor(Class[]) and setAccessible(), as the interface PrivilegedAction, allow to alter, at runtime, the visilibilty of variable, classes, or methods, even if they are private. Obviously, no one should do so, as such behavior is against everything encapsulation principal stands for."
In design ruleset:- EmptyMethodInAbstractClassShouldBeAbstract, Usability, "An empty method in an abstract class should be abstract instead, as developer may rely on this empty implementation rather than code the appropriate one."
In import ruleset:- TooManyStaticImports, Maintanability, "If you overuse the static import feature, it can make your program unreadable and unmaintainable, polluting its namespace with all the static members you import. Readers of your code (including you, a few months after you wrote it) will not know which class a static member comes from (Sun 1.5 Language Guide)."
In j2ee ruleset:- DoNotUseThreads, Usability, The J2EE specification explicitly forbid use of threads.
- MDBAndSessionBeanNamingConvention, Usability, The EJB Specification state that any MessageDrivenBean or SessionBean should be suffixed by Bean.
- RemoteSessionInterfaceNamingConvention, Usability, "Remote Home interface of a Session EJB should be suffixed by "Home".
- LocalInterfaceSessionNamingConvention, Usability, "The Local Interface of a Session EJB should be suffixed by "Local"."
- LocalHomeNamingConvention, Usability, "The Local Home interface of a Session EJB should be suffixed by "LocalHome"."
- RemoteInterfaceNamingConvention, Usability,"Remote Interface of a Session EJB should NOT be suffixed."
In strings ruleset:- UseEqualsToCompareStrings, Usability, "Using "==" or "!=" to compare strings only works if intern version is used on both sides."
In strictexception ruleset:- DoNotExtendJavaLangError, Usability, "Errors are system exceptions. Do not extend them."
In optimizations ruleset:- AddEmptyString, Efficiency, "Finds empty string literals which are being added. This is an inefficient way to convert any type to a String."
In naming ruleset: