I am trying to create a rule in the Eclipse Checkstyle plugin that will check whether the while portion of a do..while statement is on the same line as the end bracket.
My goal is to get the following to be valid:
int count = 0;
do {
System.out.println(count);
count++;
} while (count < 10);
and the below must be invalid:
int count = 0;
do {
System.out.println(count);
count++;
}
while (count < 10);
I have tried doing this by creating a Right Curly Brace placement rule (under Blocks) for the do keyword, specifying the "same" option. However, running checkstyle throws the error } should be on the same line
for both of the above examples.
Strangely enough, changing the option to "alone" causes both examples to be parsed successfully. Is there another way to enforce the above rule?
Looks like this unimplemented feature request: http://sourceforge.net/p/checkstyle/feature-requests/450/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With