java-express icon indicating copy to clipboard operation
java-express copied to clipboard

Code formatting

Open jjzazuet opened this issue 5 years ago • 6 comments

Applies automatic Google Java code formatting conventions to the full source tree.

Not a lot of difference with current formatting except:

  • Indentation size.
  • Order of a few imports.
  • Class header javadoc comments.

Thanks!

jjzazuet avatar Oct 05 '20 23:10 jjzazuet

By including the Google Java format plugin, code check-ins which violate formatting will fail the build.

To apply automatic formatting use:

gradle googleJavaFormat

jjzazuet avatar Oct 05 '20 23:10 jjzazuet

@Simonwep , are we clear to merge and keep going? Thanks.

jjzazuet avatar Oct 08 '20 04:10 jjzazuet

Sorry for the late response, yes this looks really good! Didn't know that there plugins for Java to format code and stuff 😊 (I always used the IDE)

Only one thing - I'd actually prefer 4 spaces instead of 2 (regarding overall readability), or what do you think?

simonwep avatar Oct 08 '20 05:10 simonwep

@Simonwep my apologies, as I just wrapped up a large project at work taking most of my time. Two space base indentation is generally recommended by Google's Java code style formatting conventions. A lot of projects follow it since it offers good readability in most IDEs.

https://google.github.io/styleguide/javaguide.html

Let me know if you'd prefer to keep it on 4 spaces and I'll close this PR. Thanks!

jjzazuet avatar Nov 09 '20 02:11 jjzazuet

Hey, I totally understand and I'm grateful what you've already done! I'd actually stick to 4 spaces for readability and consistency, but I'm interested in googles code formatter - would it be possible to configure it using 4 spaces? Tabs would also work as we don't need to align any properties like in JSX, but in case of large code-blocks it's hard to distinguish 10 different levels of indentation.

simonwep avatar Nov 10 '20 18:11 simonwep

Just thought i'd add, i have never see any Java project using 2 spaces.

lukeeey avatar Nov 13 '20 13:11 lukeeey