How to use Checkstyle with Eclipse formatter - indentation check problems

2,094 views
Skip to first unread message

Pavel Baranchikov

unread,
Nov 5, 2014, 10:37:36 AM11/5/14
to sevntu-c...@googlegroups.com
Hello.

    I want to use Indentation check for ages, step-by-step it becomes better, but still it doesn't conform Eclipse's formatter. This is an example of code:

    EnumValueName111("arg1                        ", Class11111111111111111111111
           
.callSomeMethod22(), createPath(Class22222222222222222222222.CONSTANT4444444,
           
Class555555.constant6), Class77777777777777777777777.constant888888),

    While running Checkstyle, I see the error, pointing to the second line:
[checkstyle] /home/user/workspace/xxx/Yyy.java:112: method call child at indentation level 12 not at correct indentation, 16

    Of course, this error is not a error of Checkstyle, which works as expected here, but I cannot use the Indentation check because my Eclipse formatter formats the string differently from what expected in Checkstyle.

    I would like to know, whether any workarounds exist or whether anybody had already faced the problem. I've found only an article https://gist.github.com/ksclarke/6ded8f83c9a6ba06b789, which does not show any ways to resolve.

    The second question is: what do you think the community should do in case of the problem? Should we try to alter Indentation check to make it conform Eclipse formatter?

Roman Ivanov

unread,
Nov 5, 2014, 1:14:51 PM11/5/14
to sevntu-c...@googlegroups.com
Hi Pavel,

first of all please try to use latest Checkstyle , we did huge update for this Check at 5.9 (to conform all indentation rules from Google Style Guide) , we still have some problem but not all of them known.

Eclipse formatter and Checkstyle Indentation are conflicting, and most users use Eclispe as formatting is minor problem, and everyone like auto-fix from Eclipse.
NO body interested in making a rules for indentation - boring task :( , and too much ideas how code should looks like during indentaion and linewrapping.

One day, as we resolve all known/reported problems in Indentaiton, we could go to Eclipse and ask them make common rules.

what do you think the community should do in case of the problem?

If you are in Eclipse , use Eclipse rules for formatting.

Should we try to alter Indentation check to make it conform Eclipse formatter?

Right now we cover Google style recommendations for indentation, we will do a bit more for even cover "syntactically parallel elements". So we focus on non related to IDE indentaion rules.
We could do reasonable changes for help be similar with Eclipse, but smb need to propose good solution for that, we do not have time tight now for this :( .

thanks,
Roman Ivanov

Roman Ivanov

unread,
Nov 5, 2014, 6:11:06 PM11/5/14
to sevntu-c...@googlegroups.com
Hi Pavel,

In eclipse there are: formatting and "Correct Indentation" independent features.
That features does not work properly with each other, so in my company we switched OFF "Correct indentation", and just use formatting.
"Correct indentation" is weird in Eclipse 4.4 .

thanks,
Roman Ivanov
Reply all
Reply to author
Forward
0 new messages