| Rule | Description | KPI | url |
|---|---|---|---|
| DoubleCheckedLocking | Partially created objects can be returned by the Double Checked Locking pattern when used in Java. An optimizing JRE may assign a reference to the baz variable before it calls the constructor of the object the reference points to. Note: With Java 5, you can make Double checked locking work, if you declare the variable to be `volatile`. | Robustness | https://pmd.github.io/pmd/pmd_rules_java.html |
| AvoidUsingShortType | Java uses the ‘short’ type to reduce memory usage, not to optimize calculation. In fact, the JVM does not have any arithmetic capabilities for the short type: the JVM must convert the short into an int, do the proper calculation and convert the int back to a short. Thus any storage gains found through use of the ‘short’ type may be offset by adverse impacts on performance. | Efficiency | https://pmd.github.io/pmd/pmd_rules_java.html |
| ConstructorCallsOverridableMethod | Calling overridable methods during construction poses a risk of invoking methods on an incompletely constructed object and can be difficult to debug. It may leave the sub-class unable to construct its superclass or forced to replicate the construction process completely within itself, losing the ability to call super(). If the default constructor contains a call to an overridable method, the subclass may be completely uninstantiable. Note that this includes method calls throughout the control flow graph – i.e., if a constructor Foo() calls a private method bar() that calls a public method buz(), this denotes a problem. | Accuracy | https://pmd.github.io/pmd/pmd_rules_java.html |
| CloseResource | Ensure that resources (like Connection, Statement, and ResultSet objects) are always closed after use. | Resource Utilization | https://pmd.github.io/pmd/pmd_rules_java.html |
| NonThreadSafeSingleton | Non-thread safe singletons can result in bad state changes. Eliminate static singletons if possible by instantiating the object directly. Static singletons are usually not needed as only a single instance exists anyway. Other possible fixes are to synchronize the entire method or to use an initialize-on-demand holder class (do not use the double-check idiom). | Robustness | https://pmd.github.io/pmd/pmd_rules_java.html |
| VariableNamingConventions | A variable naming conventions rule – customize this to your liking. Currently, it checks for final variables that should be fully capitalized and non-final variables that should not include underscores. | Understandability | https://pmd.github.io/pmd/pmd_rules_java.html |
| MethodNamingConventions | Method names should always begin with a lower case character, and should not contain underscores. | Understandability | https://pmd.github.io/pmd/pmd_rules_java.html |
| ClassNamingConventions | Class names should always begin with an upper case character. | Understandability | https://pmd.github.io/pmd/pmd_rules_java.html |
| AvoidThrowingNullPointerException | Avoid throwing NullPointerExceptions. These are confusing because most people will assume that the virtual machine threw it. Consider using an IllegalArgumentException instead; this will be clearly seen as a programmer-initiated exception. | Analyzability | https://pmd.github.io/pmd/pmd_rules_java.html |
