FHIR Chat · code styleguide for hapi and core? · hapi

Stream: hapi

Topic: code styleguide for hapi and core?


view this post on Zulip Patrick Werner (Aug 15 2019 at 11:23):

Hi,
to have a consistent code style it would be nice to have a common codestyle all agreing on.
This would also prevent commiting many untouched lines which have been modified only through beautifying/autoformat the code.

view this post on Zulip Patrick Werner (Aug 15 2019 at 11:23):

my personal favorite would be: https://google.github.io/styleguide/javaguide.html

view this post on Zulip Patrick Werner (Aug 15 2019 at 11:25):

  • 2 char indentation, which is nice on smaller displays
  • Braces are used where optional: Braces are used with if, else, for, do and while statements, even when the body is empty or contains only a single statement. <-- to me super important, ifs without braces are causing so many bugs when altered later and not paying attention to the missing braces.

view this post on Zulip Grahame Grieve (Aug 15 2019 at 11:28):

I am using 2 char indent, and I am trying to remember to use braces where they are optional

view this post on Zulip Patrick Werner (Aug 15 2019 at 11:28):

available as plugin in for IntelliJ, Eclipse install: https://github.com/HPI-Information-Systems/Metanome/wiki/Installing-the-google-styleguide-settings-in-intellij-and-eclipse

view this post on Zulip Grahame Grieve (Aug 15 2019 at 11:28):

no plugins. I hate them.

view this post on Zulip Patrick Werner (Aug 15 2019 at 11:29):

no need for a plugin, you can just File->Settings -> Editor -> Code Style

view this post on Zulip Patrick Werner (Aug 15 2019 at 11:29):

Import Scheme

view this post on Zulip Patrick Werner (Aug 15 2019 at 11:29):

https://raw.githubusercontent.com/google/styleguide/gh-pages/intellij-java-google-style.xml

view this post on Zulip Patrick Werner (Aug 15 2019 at 11:30):

This codestyle will add missing optional braces automatically

view this post on Zulip James Agnew (Aug 15 2019 at 13:28):

Not sure if this is coincidental or not, but I actually started a wiki page on the HAPI FHIR codebase's conventions here yesterday: https://github.com/jamesagnew/hapi-fhir/wiki/Contributing

I created .editorconfig files age ago that codify the 3-spaces-via-tabs in HAPI FHIR and the 2-spaces in org.hl7.fhir.core as those conventions have both existed since before the repos even knew anything about each other. Most IDEs including IJ and NetBeans just automatically pick this up and apply it, but sadly Eclipse doesn't without a plugin.

view this post on Zulip Patrick Werner (Nov 27 2019 at 16:45):

hey @James Agnew we also switched to .editorconfignow (thanks for the tip). I've converted the Google Java CodeStyle to a .editorconfig file:
https://gist.github.com/patrick-werner/1a752c624e96cd1a7c1527c5b1936970
Compatible to the 3 properties one you are using, but with a lot more features (e.g. enforce braces after if statements)

view this post on Zulip Grahame Grieve (Nov 27 2019 at 16:57):

I can see I will have to figure out how to get Eclipse configured for this

view this post on Zulip Patrick Werner (Nov 27 2019 at 19:48):

There is a Eclipse Plugin: https://github.com/ncjones/editorconfig-eclipse#readme


Last updated: Apr 12 2022 at 19:14 UTC