Analyses
by garciarmiguel@uniovi.es
|
Declare the particular checked exceptions which can be thrown by your method (es.uniovi.reflection.analyses.bloch.9.62) This rule detects methods that may throw a checked exception whose particular type is not declared in the throws clause (because a supertype is declared to be thrown instead). |
|
When you catch an exception to throw a new higher-level one, make sure to set the original exception as the cause. (es.uniovi.reflection.analyses.bloch.9.61.2) This rule detects methods that may throw a checked exception whose particular type is not declared in the throws clause (because a supertype is declared to be thrown instead). |
|
Adhere to generally accepted naming conventions (es.uniovi.reflection.analyses.bloch.8.56.2) This rule detects packages that start with 'java' or 'javax' reserved names, have no hierarchical structure with component names separated by '.', or do not follow the lowercase convention. It also detects when the default package contains any type declaration. |
|
Adhere to generally accepted naming conventions (es.uniovi.reflection.analyses.bloch.8.56.1) This rule detects types whose names do not follow the CamelCase convention. It also checks that methods, non-final local variable, parameters and fields follow the camelCase convention, excepting static final (constant) fields that must follow the SNAKE_CASE. |
|
Beware the performance of String concatenation (es.uniovi.reflection.analyses.bloch.8.51) This rule detects when the operators + or += are used to concatenate any String inside a loop. This is risky since this operation takes quadratic time and StringBuilder class must be used instead. |
|
Minimize the scope of local variables (es.uniovi.reflection.analyses.bloch.8.45) This rule detects both initialized and non-initialized local variable declarations which are not used in the following statement of the program. The rule makes the recommendation of moving these declarations before the statements in which are used for the first time. In case these first uses are located inside a try-catch block or other inner scopes (for instance, inisde if or for blocks), the declaration should be moved before the statement in which the scope changes (unless this variable is only used inside this scope). |
|
For parameter types, favor interfaces over classes (es.uniovi.reflection.analyses.bloch.7.40.2) This rule detects public method or constructor definitions in which the type of one of its parameters implements a interface that can be interchanged for the type. This interface should define all the methods and fields used in the body of the method. The change should not affect the rest of the implementation (those regarding lvalue types in assignments and method invocations where the parameter is passed as argument), but may generate small errors that could be solved with easy fixes. |
|
Check parameters for validity (es.uniovi.reflection.analyses.bloch.7.38) This rule detects public method or constructor definitions that declare a parameter used inside, but there is no previous validity check performed on it. Any use of the parameter inside an if or assert condition will be understood as a validity check. |
|
Consistently use the Override annotation (es.uniovi.reflection.analyses.bloch.6.36) This rule detects methods, defined in one of its supertypes, which have the same name and parameter types. If this method has no Override annotation, a warning is prompted. |
|
Minimize the accessibility of fields (es.uniovi.reflection.analyses.bloch.4.13.2) This rule detects non-private fields that should be private. The only exceptions allowed are constants (static final fields) and package-private fields used in a different compilation unit. |
|
Minimize the accessibility of classes (es.uniovi.reflection.analyses.bloch.4.13.1) This rule detects public classes that are only used inside its own package in order to change its visibility to "package-protected" so it cannot be visible for the client (**Scenario 1**). Moreover, this rule also detects public and package-protected classes that are only used inside one class in order to tranform the first class into a inner one inside the class where it is being used, changing its visibility to private (**Scenario 2**). |
|
Always override hashCode when you override equals (es.uniovi.reflection.analyses.bloch.3.9) This rule detects classes that implement only one of the hashCode and equals methods. In this scenario, both methods must be implemented to preserve the general contract for the hashCode method. |
|
Provide public access for every field used in the toString method (es.uniovi.reflection.analyses.bloch.3.10s) This rule detects classes that do not provide public getters to access fields which are used in expressions returned by the toString method. |
|
Always override toString (es.uniovi.reflection.analyses.bloch.3.10) This rule detects classes not implementing/redefining the toString method when this method is being invoked somewhere in the code. |
|
Enforce noninstanciability with a private constructor (es.uniovi.reflection.analyses.bloch.2.4) This rule detects static classes (with only static members) without a private constructor in order to enforce noninstanciability by implementing this missing private constructor in those classes. |