Since Checkstyle 3.4
for ( ; i < j; i++, j--)
name | description | type | default value | since |
---|---|---|---|---|
option | Specify policy on how to pad an empty for iterator. | PadOption | nospace |
3.4 |
To configure the check:
<module name="Checker"> <module name="TreeWalker"> <module name="EmptyForInitializerPad"/> </module> </module>
Example:
class Example1 { int i = 0; void example() { for ( ; i < 1; i++ ); // violation '';' is preceded with whitespace' for (; i < 2; i++ ); for (;i<2;i++); for ( ;i<2;i++); // violation '';' is preceded with whitespace' for ( ; i < 2; i++ ); } }
To configure the check to require white space at an empty for iterator:
<module name="Checker"> <module name="TreeWalker"> <module name="EmptyForInitializerPad"> <property name="option" value="space"/> </module> </module> </module>
Example:
class Example2 { int i = 0; void example() { for ( ; i < 2; i++ ) { }; for (; i < 2; i++ ) { }; // violation '';' is not preceded with whitespace' for (;i<2;i++) { }; // violation '';' is not preceded with whitespace' for ( ;i<2;i++) { }; for ( ; i < 2; i++ ); } }
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.whitespace