Since Checkstyle 3.4
allowLineBreaks
to
true
.
name | description | type | default value | since |
---|---|---|---|---|
allowLineBreaks | Allow a line break between the identifier and left parenthesis. | boolean | false |
3.4 |
option | Specify policy on how to pad method parameter. | PadOption | nospace |
3.4 |
tokens | tokens to check | subset of tokens CTOR_DEF , CTOR_CALL , LITERAL_NEW , METHOD_CALL , METHOD_DEF , SUPER_CTOR_CALL , ENUM_CONSTANT_DEF , RECORD_DEF , RECORD_PATTERN_DEF . | CTOR_DEF , CTOR_CALL , LITERAL_NEW , METHOD_CALL , METHOD_DEF , SUPER_CTOR_CALL , ENUM_CONSTANT_DEF , RECORD_DEF , RECORD_PATTERN_DEF . | 3.4 |
To configure the check:
<module name="Checker"> <module name="TreeWalker"> <module name="MethodParamPad"/> </module> </module>
Example:
class Example1 { public Example1() { super(); } public Example1 (int aParam) { // violation ''(' is preceded with whitespace' super (); // violation ''(' is preceded with whitespace' } public void method() {} public void methodWithVeryLongName () {} // violation ''(' should be on the previous line.' }
To configure the check to require a space after the identifier of a method definition, except if the left parenthesis occurs on a new line:
<module name="Checker"> <module name="TreeWalker"> <module name="MethodParamPad"> <property name="allowLineBreaks" value="true"/> <property name="option" value="space"/> <property name="tokens" value="METHOD_DEF"/> </module> </module> </module>
Example:
class Example2 { public Example2() { super(); } public Example2 (int aParam) { super (); } public void method() {} // violation ''(' is not preceded with whitespace' public void methodWithVeryLongName () {} // OK, because allowLineBreaks is true }
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