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

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



OneDeclarationPerLine

OneDeclarationPerLine

Java allows the use of several variables declaration of the same type on one line. However, it can lead to quite messy code. This rule looks for several declarations on the same line.

                    
//LocalVariableDeclaration
   [count(VariableDeclarator) > 1]
   [$strictMode or count(distinct-values(VariableDeclarator/@BeginLine)) != count(VariableDeclarator)]
                    

Example(s):

          
String name;            // separate declarations
String lastname;

String name, lastname;  // combined declaration, a violation

String name,
       lastname;        // combined declaration on multiple lines, no violation by default.
                        // Set property strictMode to true to mark this as violation.
          




© 2015 - 2024 Weber Informatics LLC | Privacy Policy