MultipleVariableDeclarations

Since Checkstyle 3.4

Description

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.

Examples

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

Example of Usage

Violation Messages

All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.

Package

com.puppycrawl.tools.checkstyle.checks.coding

Parent Module

TreeWalker