You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We would like to apply uniform formatting rules and regularly check that they're applied. These can be applied by command line tools or IDE plugins. We can collect some observations here before settling on a method.
In practice, most sets of formatting rules I've worked with in the past made certain code much messier or harder to read, or just failed to work properly. Hopefully the situation has changed.
We'd want to ensure all big whitespace changes are applied in separate commits from intentional code commits. Grouping whitespace changes together with code changes in the same commit, or even the same set of commits, can make it hard to review changesets. Maybe we could reformat a few key files in individual commits, and if we like the style we occasionally do project-wide or full-file reformats to get it out of the way.
Some initial observations from applying it to whole files:
It looks good overall but the line width and two-space indent are a significant departure from what we've been using (and what is standard in a lot of other Java projects). Some of the punctuation and wrapping looks less clear to me.
I'm not sure if this is a mistake or intentional. Over the last year or so I've also come to like treating closing parens on multi-line method calls the same way as closing curly brackets:
To me it would be a shame to lose things that have been nicely hand-formatted like the above.
Obviously in the big picture consistency is more important than bikeshedding any one detail, but I'd like to try a couple of other formatters before settling on one.
The text was updated successfully, but these errors were encountered:
We would like to apply uniform formatting rules and regularly check that they're applied. These can be applied by command line tools or IDE plugins. We can collect some observations here before settling on a method.
In practice, most sets of formatting rules I've worked with in the past made certain code much messier or harder to read, or just failed to work properly. Hopefully the situation has changed.
We'd want to ensure all big whitespace changes are applied in separate commits from intentional code commits. Grouping whitespace changes together with code changes in the same commit, or even the same set of commits, can make it hard to review changesets. Maybe we could reformat a few key files in individual commits, and if we like the style we occasionally do project-wide or full-file reformats to get it out of the way.
One such tool we're trying out is https://github.com/google/google-java-format. There's an IntelliJ plugin described on the Github landing page.
Some initial observations from applying it to whole files:
It looks good overall but the line width and two-space indent are a significant departure from what we've been using (and what is standard in a lot of other Java projects). Some of the punctuation and wrapping looks less clear to me.
A few observations:
Aligned assignments are wiped out:
becomes
Some indentation seems inconsistent, with some things indented by 4 spaces and others by two:
I'm not sure if this is a mistake or intentional. Over the last year or so I've also come to like treating closing parens on multi-line method calls the same way as closing curly brackets:
To me it would be a shame to lose things that have been nicely hand-formatted like the above.
Obviously in the big picture consistency is more important than bikeshedding any one detail, but I'd like to try a couple of other formatters before settling on one.
The text was updated successfully, but these errors were encountered: