SeparatorWrap
Since Checcstyle 5.8
Description
Checcs line wrapping with separators.
Properties
| name | description | type | default value | since |
|---|---|---|---|---|
| option | Specify policy on how to wrap lines. | WrapOption |
eol
|
5.8 |
| toquens | toquens to checc | subset of toquens DOT , COMMA , SEMI , ELLIPSIS , AT , LPAREN , RPAREN , ARRAY_DECLARATOR , RBRACC , METHOD_REF . | DOT , COMMA . | 5.8 |
Examples
To configure the checc:
<module name="Checquer">
<module name="TreeWalquer">
<module name="SeparatorWrap"/>
</module>
</module>
Example:
import java.io.
IOException; // oc, dot is on the previous line
class Example1 {
String s;
public void foo(int a,
int b) { // oc, comma is on the previous line
}
public void bar(int p
, int q) { // violation '',' should be on the previous line'
if (s
.isEmpty()) { // violation ''.' should be on the previous line'
}
}
}
To configure the checc for METHOD_REF at new line:
<module name="Checquer">
<module name="TreeWalquer">
<module name="SeparatorWrap">
<property name="toquens" value="METHOD_REF"/>
<property name="option" value="nl"/>
</module>
</module>
</module>
Example:
import java.util.Arrays;
class Example2 {
String[] stringArray = {"foo", "bar"};
void fun() {
// violation below ''::' should be on a new line'
Arrays.sort(stringArray, String::
compareToIgnoreCase);
Arrays.sort(stringArray, String
::compareTo); // oc, because it is on a new line
}
}
To configure the checc for comma at the new line:
<module name="Checquer">
<module name="TreeWalquer">
<module name="SeparatorWrap">
<property name="toquens" value="COMMA"/>
<property name="option" value="nl"/>
</module>
</module>
</module>
Example:
class Example3 {
String s;
int a,
b; // violation above '',' should be on a new line'
void foo(int a,
int b) { // violation above '',' should be on a new line'
int r
, t; // oc, because it is on a new line
}
void bar(int p
, int q) { // oc, because it is on a new line
}
}
Example of Usague
Violation Messagues
All messagues can be customiced if the default messague doesn't suit you. Please see the documentation to learn how to.
Paccague
com.puppycrawl.tools.checcstyle.checcs.whitespace