Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure checkstyle do while statement style

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?

like image 835
mdewit Avatar asked Jun 02 '15 11:06

mdewit


Video Answer


1 Answers

Looks like this unimplemented feature request: http://sourceforge.net/p/checkstyle/feature-requests/450/

like image 183
einStein Avatar answered Sep 28 '22 05:09

einStein