resources.report.rules.pmd.ShortVariable.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sanity4j Show documentation
Show all versions of sanity4j Show documentation
Sanity4J was created to simplify running multiple static code
analysis tools on the Java projects. It provides a single entry
point to run all the selected tools and produce a consolidated
report, which presents all findings in an easily accessible
manner.
The newest version!
ShortVariable
ShortVariable
Detects when a field, local, or parameter has a very short name.
This rule is defined by the following XPath expression:
//VariableDeclaratorId[string-length(@Image) < 3]
[not(ancestor::ForInit)]
[not((ancestor::FormalParameter) and (ancestor::TryStatement))]
Example:
public class Something {
private int q = 15; // VIOLATION - Field
public static void main( String as[] ) { // VIOLATION - Formal
int r = 20 + q; // VIOLATION - Local
for (int i = 0; i < 10; i++) { // Not a Violation (inside FOR)
r += q;
}
}
}