
resources.report.rules.pmd.ShortVariable.html Maven / Gradle / Ivy
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;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy