JavaHamcrest icon indicating copy to clipboard operation
JavaHamcrest copied to clipboard

Introduce a consistent Code style

Open alb-i986 opened this issue 6 years ago • 5 comments

While working on #294 I noticed there's a bit of a mess from a code style point of view. See e.g. IsCollectionWithSize: there's a mix of tabs with 2 spaces and others with 4 spaces.

alb-i986 avatar Apr 19 '20 13:04 alb-i986

That's unfortunate. My preference is for 2 spaces (I like to conserve horizontal line space). This is not just the thing about initial indentation vs further indentation?

sf105 avatar Apr 19 '20 14:04 sf105

If it is simply an indentation concern, then I think it's straightforward to address that using CheckStyle to assist with a consistent code style. I've opened up a PR which adds such a rule.

brownian-motion avatar Apr 20 '20 02:04 brownian-motion

Yes, thanks @brownian-motion, that's what I meant. Shall we go a little further and provide a code style settings so that everyone is on the same page and up & running in few secs?

alb-i986 avatar Apr 20 '20 06:04 alb-i986

I like this idea, but I'm only familiar with a small set of style settings. I know IntelliJ can import code style from CheckStyle, can Eclipse or other IDEs do the same? If all can, it may be simple enough to define a CheckStyle file.

brownian-motion avatar Apr 21 '20 02:04 brownian-motion

I don't know, but if we want to keep it simple, we may just use Google's styles: they are using 2 spaces anyways. https://github.com/google/styleguide They provide both for Eclipse and Intellij.

alb-i986 avatar Apr 22 '20 16:04 alb-i986