-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reformat source code for consistent use of whitespace. #153
Conversation
+1! |
Thanks for doing this @heuermh! The code style and particularly the whitespace is particularly inconsistent in this codebase, so I'm +1 on fixing it. I think we should do it in a major release, though, since it's quite a disruptive change. Also, I think we should enforce the style by using checkstyle or similar. I started writing a PR a while ago to do this, it's incomplete, but you can see the idea here: https://github.com/HadoopGenomics/Hadoop-BAM/compare/master...tomwhite:checkstyle?expand=1 What do you think? |
I agree, and as an example have it configured here We would need to sync the configuration in the source code formatter with that enforced by checkstyle. ADAM formats source on the fly as part of the build, I think that might be more trouble than it is worth. |
Great!
Agreed. |
+1 |
9293243
to
3a534d0
Compare
Rather than choosing our own formatting preferences, I would rather choose an existing style guide to use. The Google Java Style Guide looks like the one that is most used these days (the old Sun one has not been updated since 1999). At first I thought we should use Checkstyle to enforce the style, but after playing with the Google checkstyle settings I found that they produce lots (hundreds) of warnings even for source code that has been formatted to adhere to the Google Java Style Guide. For example, it produces lots of warnings about there not being blank lines between import groups even though the guide says there shouldn't be blank lines. So I think it would be preferable to use a tool that checks if the source is formatted correctly according to the Google Java Style Guide, and fail the build if it's not. This is such a tool: https://github.com/coveo/fmt-maven-plugin, and it's easy to integrate with the Maven build. The source can also be manually reformatted using I've produce a patch to do this here: #182. Please take a look! |
The Google Java Style Guide looks fairly reasonable to me. The only thing I don't like is the missing newline after return () -> {
while (condition()) {
method();
}
};
return new MyClass() {
@Override public void method() {
if (condition()) {
try {
something();
}
catch (ProblemException e) {
recover();
}
}
else if (otherCondition()) {
somethingElse();
}
else {
lastThing();
}
}
}; to return () -> {
while (condition()) {
method();
}
};
return new MyClass() {
@Override public void method() {
if (condition()) {
try {
something();
} catch (ProblemException e) {
recover();
}
} else if (otherCondition()) {
somethingElse();
} else {
lastThing();
}
}
}; I could of course could be outvoted. :) |
+1 to using the Google Java style guide. |
Closing as WontFix |
Fixes #147.
I created a code style for Intellij IDEA (checked in at
etc/IntelliJ IDEA Code Style.xml
) and ran Reformat Code. All source code changes should be whitespace and braces only.