All Downloads are FREE. Search and download functionalities are using the official Maven repository.

resources.report.rules.pmd.ShortVariable.html Maven / Gradle / Ivy

Go to download

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;
    }
  }
}

    
            




© 2015 - 2024 Weber Informatics LLC | Privacy Policy