gofmt for Java

728 views
Skip to first unread message

Philip Durbin

unread,
Oct 19, 2016, 10:17:35 AM10/19/16
to datave...@googlegroups.com
After playing around with Go a bit I'm fairly convinced that I'd like to find a `gofmt` for Java and beg every Dataverse contributor to use it.

If you're unfamiliar with gofmt, https://blog.golang.org/go-fmt-your-code provides a nice overview of why you would want to programmatically format all the code in a project using a tool that is not tied to any IDE:

- easier to write: never worry about minor formatting concerns while hacking away,
- easier to read: when all code looks the same you need not mentally convert others' formatting style into something you can understand.
- easier to maintain: mechanical changes to the source don't cause unrelated changes to the file's formatting; diffs show only the real changes.
- uncontroversial: never have a debate about spacing or brace position ever again!

The first step is to find a gofmt for Java. At http://irclog.greptilian.com/friendlyjava/2016-10-19 a tool called formatter-maven-plugin was suggested: https://github.com/revelc/formatter-maven-plugin

Is there a different command-line tool you would prefer? Please let me know! Thanks!

Happy hacking!

Phil

p.s. This very strongly relates to the Google Doc linked from http://guides.dataverse.org/en/4.5.1/developers/coding-style.html . It's called "Dataverse Coding Standards and Style Guide" and here's a handy link: https://docs.google.com/document/d/1KTd3FpM1BI3HlBofaZjMmBiQEJtFf11jiiGpQeJzy7A/edit?usp=sharing . The conversation initially started at https://github.com/IQSS/dataverse/issues/775

bill mckinney

unread,
Oct 19, 2016, 11:12:35 AM10/19/16
to Dataverse Dev, philip...@harvard.edu
Another approach is to create a shared Eclipse style formatter XML file which can also be imported into both NetBeans and IntelliJ. Here's an example of one that conforms to Google's style: https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml

--Bill

Philip Durbin

unread,
Oct 19, 2016, 12:13:05 PM10/19/16
to datave...@googlegroups.com
Bill, I *love* the idea (thanks!) but it looks like it doesn't work with Netbeans: Add Java style for Netbeans - https://github.com/google/styleguide/issues/56

Michael, you probably know more about Netbeans than any of us. Do you think you could get Bill's suggestion to work? I also asked in #netbeans: https://javabot.evanchooly.com/logs/%23netbeans/2016-10-19#58079b580a975a76c126c486

--
You received this message because you are subscribed to the Google Groups "Dataverse Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dataverse-dev+unsubscribe@googlegroups.com.
To post to this group, send email to datave...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dataverse-dev/3480a3fc-6d55-48b9-ad88-d721e1b9b371%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Philip Durbin

unread,
Oct 21, 2016, 4:20:54 PM10/21/16
to datave...@googlegroups.com
Geertjan Wielenga, the product manager of Netbeans, got back to me and suggested that http://plugins.netbeans.org/plugin/50877/eclipse-code-formatter-for-java-eclipse-mars-4-5 might be a way to use the file Bill mentioned ( https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml ) in Netbeans.

I also created this issue to document whatever we decide in the dev guide: https://github.com/IQSS/dataverse/issues/3418

Comments and suggestions on that issue and more discussion on this list are certainly welcome!

Philip Durbin

unread,
Sep 27, 2018, 12:12:49 PM9/27/18
to datave...@googlegroups.com
In https://github.com/IQSS/dataverse/pull/5106 I'm suggesting that we start using Checkstyle based on some config offered by contributor Oliver Bertuch (poikilotherm on GitHub and IRC). Please take a look.

Thanks!

Phil

To unsubscribe from this group and stop receiving emails from it, send an email to dataverse-de...@googlegroups.com.

To post to this group, send email to datave...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dataverse-dev/3480a3fc-6d55-48b9-ad88-d721e1b9b371%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages