Since Checkstyle 3.4
Checks that each variable declaration is in its own statement and on its own line.
Rationale: the Java code conventions chapter 6.1 recommends that declarations should be one per line/statement.
To configure the check:
<module name="Checker"> <module name="TreeWalker"> <module name="MultipleVariableDeclarations"/> </module> </module>
Example:
public class Test { public void myTest() { int mid; int high; // ... int lower, higher; // violation // ... int value, index; // violation // ... int place = mid, number = high; // violation } }
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.coding